@@ -0,0 +1,232 @@ | |||
<?php | |||
/** | |||
* 全局通用方法集合 | |||
* ============================================================================ | |||
* * 版权所有 蜘蛛出行 * * | |||
* 网站地址: http://www.zhizhuchuxing.com | |||
* ---------------------------------------------------------------------------- | |||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 | |||
* 使用;不允许对程序代码以任何形式任何目的的再发布。 | |||
* ============================================================================ | |||
* Author By: 倪宗锋 | |||
* PhpStorm Util.php | |||
* Create By 2017/2/22 19:44 $ | |||
*/ | |||
namespace app\admin\command; | |||
use common\models\AdmUser; | |||
use common\models\FxUser; | |||
use common\models\LogUserOperation; | |||
use common\models\OrderMain; | |||
use common\models\ProdCategory; | |||
use common\models\ShUser; | |||
use yii\base\Exception; | |||
class Util | |||
{ | |||
/** | |||
* Function Description:返回成功数组数据 | |||
* Function Name: returnArrSu | |||
* @param string $msg 提示信息 | |||
* @param string $url 跳转地址 | |||
* @param string|array $data 需要传递的数据 | |||
* @param string $code 错误码 | |||
* | |||
* @return array | |||
* | |||
* @author 倪宗锋 | |||
*/ | |||
public static function returnArrSu($msg = '', $data = '', $url = '', $code = '') | |||
{ | |||
$return = array(); | |||
$return['flag'] = true; | |||
$return['msg'] = $msg; | |||
$return['url'] = $url; | |||
$return['code'] = $code; | |||
$return['data'] = $data; | |||
return $return; | |||
} | |||
/** | |||
* Function Description:返回错误数组数据 | |||
* Function Name: returnArrEr | |||
* @param string $msg 提示信息 | |||
* @param string $url 跳转地址 | |||
* @param string|array $data 需要传递的数据 | |||
* @param string $code 错误码 | |||
* | |||
* @return array | |||
* | |||
* @author 倪宗锋 | |||
*/ | |||
public static function returnArrEr($msg = '', $data = '', $url = '', $code = '') | |||
{ | |||
$return = array(); | |||
$return['flag'] = false; | |||
$return['msg'] = $msg; | |||
$return['url'] = $url; | |||
$return['code'] = $code; | |||
$return['data'] = $data; | |||
return $return; | |||
} | |||
/** | |||
* Function Description:json转换为xml | |||
* Function Name: jsonToXml | |||
* @param $json | |||
* | |||
* @return bool|string | |||
* | |||
* @author 倪宗锋 | |||
*/ | |||
public static function jsonToXml($json) | |||
{ | |||
if (empty($json)) { | |||
return false; | |||
} | |||
$array = json_decode($json); | |||
$xml = ''; | |||
$xml .= '<?xml version="1.0" encoding="UTF-8"?>' . self::arraysToXml(['response' => $array]); | |||
return $xml; | |||
} | |||
/** | |||
* Function Description:数组转换成xml | |||
* Function Name: arrayToXml | |||
* @param $array | |||
* @param $key | |||
* @return string | |||
* | |||
* @author 倪宗锋 | |||
*/ | |||
public static function arraysToXml($array, $key = '') | |||
{ | |||
$string = ''; | |||
if (count($array) == 0) { | |||
return ''; | |||
} | |||
foreach ($array as $k => $v) { | |||
if (is_array($v) && isset($v['0'])) { | |||
$string .= self::arraysToXml($v, $k);//是数组或者对像就的递归调用 | |||
} else { | |||
if ($key != '') { | |||
$k = $key; | |||
} | |||
$string .= '<' . $k . '>'; | |||
if (is_array($v) || is_object($v)) {//判断是否是数组,或者,对像 | |||
$string .= self::arraysToXml($v);//是数组或者对像就的递归调用 | |||
} elseif (is_numeric($v)) { | |||
$string .= $v; | |||
} elseif ($v != '') { | |||
$string .= '<![CDATA[' . $v . ']]>'; | |||
} else { | |||
$string .= ''; | |||
} | |||
$string .= '</' . $k . '>'; | |||
} | |||
} | |||
return $string; | |||
} | |||
/** | |||
* Function Description:xml转换为json | |||
* Function Name: xml_to_json | |||
* @param $source | |||
* | |||
* @return string | |||
* | |||
* @author 倪宗锋 | |||
*/ | |||
public static function xmlToJson($source) | |||
{ | |||
if (is_file($source)) { //传的是文件,还是xml的string的判断 | |||
$xml_array = simplexml_load_file($source); | |||
} else { | |||
$xml_array = simplexml_load_string(trim($source)); | |||
} | |||
$json = json_encode($xml_array, true); | |||
return $json; | |||
} | |||
/** | |||
* Function Description:xml转换成数组 | |||
* Function Name: xmlToArray | |||
* @param $source | |||
* | |||
* @return mixed | |||
* | |||
* @author 倪宗锋 | |||
*/ | |||
public static function xmlToArray($source) | |||
{ | |||
libxml_disable_entity_loader(true); | |||
$getResult = json_decode(json_encode(simplexml_load_string(trim($source), 'SimpleXMLElement', LIBXML_NOCDATA)), true); | |||
return $getResult; | |||
} | |||
/** Function Description:加密解密函数 | |||
* Function Name: authCode | |||
* @param $string | |||
* @param string $operation | |||
* @param int $expiry | |||
* @return string|array | |||
* @author 倪宗锋 | |||
*/ | |||
static function authCode($string, $operation = 'DECODE', $expiry = 0) | |||
{ | |||
$key = 'udM5A8S50eg8veH15dd0m601de7073N8Bcn7d1I8Res7C7o7z274D6y342I4C7t7'; | |||
$ckey_length = 4; // 随机密钥长度 取值 0-32; | |||
// 加入随机密钥,可以令密文无任何规律,即便是原文和密钥完全相同,加密结果也会每次不同,增大破解难度。 | |||
// 取值越大,密文变动规律越大,密文变化 = 16 的 $ckey_length 次方 | |||
// 当此值为 0 时,则不产生随机密钥 | |||
$key = md5($key); | |||
$keya = md5(substr($key, 0, 16)); | |||
$keyb = md5(substr($key, 16, 16)); | |||
$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length) : substr(md5(microtime()), -$ckey_length)) : ''; | |||
$cryptkey = $keya . md5($keya . $keyc); | |||
$key_length = strlen($cryptkey); | |||
$string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0) . substr(md5($string . $keyb), 0, 16) . $string; | |||
$string_length = strlen($string); | |||
$result = ''; | |||
$box = range(0, 255); | |||
$rndkey = array(); | |||
for ($i = 0; $i <= 255; $i++) { | |||
$rndkey[$i] = ord($cryptkey[$i % $key_length]); | |||
} | |||
for ($j = $i = 0; $i < 256; $i++) { | |||
$j = ($j + $box[$i] + $rndkey[$i]) % 256; | |||
$tmp = $box[$i]; | |||
$box[$i] = $box[$j]; | |||
$box[$j] = $tmp; | |||
} | |||
for ($a = $j = $i = 0; $i < $string_length; $i++) { | |||
$a = ($a + 1) % 256; | |||
$j = ($j + $box[$a]) % 256; | |||
$tmp = $box[$a]; | |||
$box[$a] = $box[$j]; | |||
$box[$j] = $tmp; | |||
$result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); | |||
} | |||
if ($operation == 'DECODE') { | |||
if ((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26) . $keyb), 0, 16)) { | |||
return substr($result, 26); | |||
} else { | |||
return ''; | |||
} | |||
} else { | |||
return $keyc . str_replace('=', '', base64_encode($result)); | |||
} | |||
} | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace app\admin\controller; | |||
use app\admin\model\Area; | |||
use app\admin\service\OrderMainService; | |||
use app\common\controller\Backend; | |||
use think\Db; | |||
use think\exception\PDOException; | |||
@@ -221,6 +222,61 @@ class OrderMain extends Backend | |||
return json($result); | |||
} | |||
/** | |||
* 订单页面保存接口 | |||
* @return \think\response\Json | |||
*/ | |||
public function save(){ | |||
$params=$this->request->post(); | |||
$orderMainService = new OrderMainService(); | |||
Db::startTrans(); | |||
$result = $orderMainService->saveOrder($params); | |||
if (!$result['flag']) { | |||
Db::rollback(); | |||
} else { | |||
Db::commit(); | |||
} | |||
return json($result); | |||
} | |||
/** | |||
* 子订单保存接口 | |||
* @return \think\response\Json | |||
*/ | |||
public function subOrderSave(){ | |||
$params=$this->request->post(); | |||
$orderMainService = new OrderMainService(); | |||
Db::startTrans(); | |||
$result = $orderMainService->subOrderSave($params); | |||
if (!$result['flag']) { | |||
Db::rollback(); | |||
} else { | |||
Db::commit(); | |||
} | |||
return json($result); | |||
} | |||
/** | |||
* 删除子订单 | |||
* @return \think\response\Json | |||
*/ | |||
public function delSubOrder(){ | |||
$params=$this->request->post(); | |||
$orderMainService = new OrderMainService(); | |||
$result = $orderMainService->delSubOrder($params); | |||
return json($result); | |||
} | |||
/** | |||
* 获取订单详情 | |||
* @return \think\response\Json | |||
*/ | |||
public function getShowInfo(){ | |||
$params=$this->request->post(); | |||
$orderMainService = new OrderMainService(); | |||
$result = $orderMainService->getOrderInfo($params['id']); | |||
return json($result); | |||
} | |||
public function newAdd(){ | |||
$params=$this->request->post(); | |||
@@ -20,7 +20,7 @@ return [ | |||
'Check_out_date' => '离店时间', | |||
'Prod_num' => '产品数量', | |||
'Total_price' => '总金额 ', | |||
'Total_cose' => '总成本价格', | |||
'Total_cost' => '总成本价格', | |||
'Profit' => '利润', | |||
'Log' => '日志', | |||
'Del_flag' => '是否删除', | |||
@@ -11,7 +11,7 @@ return [ | |||
'Use_date' => '使用日期', | |||
'Prod_num' => '产品数量', | |||
'Total_price' => '总金额', | |||
'Total_cose' => '总成本价格', | |||
'Total_cost' => '总成本价格', | |||
'Profit' => '利润', | |||
'Log' => '日志', | |||
'Country_name' => '国家名称', | |||
@@ -0,0 +1,220 @@ | |||
<?php | |||
/** | |||
* Created by PhpStorm. | |||
* User: nizongfeng | |||
* Date: 2021/10/27 | |||
* Time: 13:36 | |||
*/ | |||
namespace app\admin\service; | |||
use app\admin\command\Util; | |||
use app\admin\model\CfRoomInfo; | |||
use app\admin\model\OrderHotel; | |||
use app\admin\model\Purchase; | |||
use think\Exception; | |||
class OrderHotelDao | |||
{ | |||
/** | |||
* 更新记录 | |||
* @param $param | |||
* @param $orderId | |||
* @return array|string | |||
*/ | |||
public function modify($param, $orderId) | |||
{ | |||
$hotelInfo = $this->getHotelInfo($param['hotel_id']); | |||
if (!$hotelInfo['flag']){ | |||
return $hotelInfo; | |||
} | |||
$roomInfo = $this->getRoomInfo($param['room_id']); | |||
if (!$roomInfo['flag']){ | |||
return $roomInfo; | |||
} | |||
$roomPlan = $this->getRoomPlan($param['plan_id']); | |||
if (!$roomPlan['flag']) { | |||
return $roomPlan; | |||
} | |||
try { | |||
//设置入参 | |||
$data = [ | |||
"order_id" => $orderId, | |||
"hotel_id" => $param['hotel_id'], | |||
"hotel_name" => $hotelInfo['data']['hotel_name'], | |||
"hotel_phone" => $hotelInfo['data']['hotel_phone'], | |||
"country_name" => $hotelInfo['data']['country_name'], | |||
"province_name" => $hotelInfo['data']['province_name'], | |||
"city_name" => $hotelInfo['data']['city_name'], | |||
"detail_address" => $hotelInfo['data']['detail_address'], | |||
//房型 | |||
"room_id" => $param['data']['room_id'], | |||
"room_name" => $roomInfo['data']['room_name'], | |||
"room_memo" => $roomInfo['data']['room_memo'], | |||
//价格方案 | |||
"plan_id" => $param['data']['plan_id'], | |||
"plan_name" => $roomPlan['data']['plan_name'], | |||
"plan_memo" => $roomPlan['data']['plan_memo'], | |||
//其他 | |||
"check_in_date" => $param['check_in_date'], | |||
"check_out_date" => $param['check_out_date'], | |||
"confirm_status" => $param['confirm_status'], | |||
"confirm_no" => $param['confirm_no'], | |||
"customer_name" => $param['customer_name'], | |||
"customer_comments" => $param['customer_comments'], | |||
"trade_order_number" => $param['trade_order_number'], | |||
"res_person" => $param['res_person'], | |||
"res_person_id" => $param['res_person_id'], | |||
"del_flag"=>0 | |||
]; | |||
$orderHotelModel = new OrderHotel(); | |||
if (empty($param['id'])) { | |||
$id = $orderHotelModel->insertGetId($data); | |||
return Util::returnArrSu($id); | |||
}else { | |||
$orderHotelModel->save($data, ["id" => $param['id']]); | |||
return Util::returnArrSu($param['id']); | |||
} | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("更新酒店子订单失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 获取酒店信息 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getHotelInfo($id) | |||
{ | |||
try { | |||
$model = new OrderHotel(); | |||
$result = $model->where(["id" => $id])->find(); | |||
if ($result == null) { | |||
return Util::returnArrEr("获取酒店信息失败" . $id); | |||
} | |||
return Util::returnArrSu($result); | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("获取酒店信息失败" . $id); | |||
} | |||
} | |||
/** | |||
* 获取房型详情 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getRoomInfo($id) | |||
{ | |||
try { | |||
$model = new CfRoomInfo(); | |||
$result = $model->where(["id" => $id])->find(); | |||
if ($result == null) { | |||
return Util::returnArrEr("获取房型信息失败" . $id); | |||
} | |||
return Util::returnArrSu($result); | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("获取房型信息失败" . $id); | |||
} | |||
} | |||
/** | |||
* 获取房型价格方案 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getRoomPlan($id) | |||
{ | |||
try { | |||
$model = new CfRoomInfo(); | |||
$result = $model->where(["id" => $id])->find(); | |||
if ($result == null) { | |||
return Util::returnArrEr("获取价格方案信息失败" . $id); | |||
} | |||
return Util::returnArrSu($result); | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("获取价格方案信息失败" . $id); | |||
} | |||
} | |||
/** | |||
* 设置子订单金额 | |||
* @param int $subOrderId | |||
* @return array | |||
*/ | |||
public function setSubOrderAmount( int $subOrderId) { | |||
try{ | |||
$purchaseModel = new Purchase(); | |||
$purchaseList = $purchaseModel->where(["order_detail_id"=>$subOrderId,"del_flag"=>0])->select(); | |||
$cost = 0; | |||
$amount = 0; | |||
$count = 0; | |||
foreach ($purchaseList as $purchase) { | |||
$cost += $purchase['total_cost']; | |||
$amount += $purchase['total_price']; | |||
$count += $purchase['count']; | |||
} | |||
OrderHotel::update(["total_price"=>$amount,"total_cost"=>$cost,"count"=>$count])->where(["id"=>$subOrderId]); | |||
return Util::returnArrSu(); | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("更新酒店订单子表金额失败".$subOrderId); | |||
} | |||
} | |||
/** | |||
* 获取详情 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getInfoById($id) { | |||
try { | |||
$model = new OrderHotel(); | |||
$result = $model->where(["id" => $id])->find(); | |||
if ($result == null) { | |||
return Util::returnArrEr("获取子订单信息失败" . $id); | |||
} | |||
return Util::returnArrSu($result); | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("获取子订单信息失败" . $id); | |||
} | |||
} | |||
/** | |||
* 删除记录 | |||
* @param $order_id | |||
*/ | |||
public function delete($order_id){ | |||
$model = new OrderHotel(); | |||
$model->save(["del_flag"=>1],["order_id"=>$order_id]); | |||
} | |||
/** | |||
* 删除记录 | |||
* @param $id | |||
*/ | |||
public function delById($id) { | |||
$model = new OrderHotel(); | |||
$model->save(["del_flag"=>1],["id"=>$id]); | |||
} | |||
/** | |||
* 获取酒店子订单列表 | |||
* @param $orderId | |||
* @return array | |||
*/ | |||
public function getListByOrderId($orderId){ | |||
$subOrderModel = new OrderHotel(); | |||
try { | |||
$subOrderList = $subOrderModel->where(["order_id" => $orderId, "del_flag" => 0])->select(); | |||
if (null == $subOrderList) { | |||
return Util::returnArrEr([]); | |||
} | |||
return Util::returnArrSu($subOrderList); | |||
}catch (Exception $e) { | |||
return Util::returnArrEr("获取酒店订单列表异常".$e->getMessage()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,175 @@ | |||
<?php | |||
/** | |||
* Created by PhpStorm. | |||
* User: nizongfeng | |||
* Date: 2021/10/27 | |||
* Time: 13:36 | |||
*/ | |||
namespace app\admin\service; | |||
use app\admin\command\Util; | |||
use app\admin\model\CfItem; | |||
use app\admin\model\OrderHotel; | |||
use app\admin\model\OrderItem; | |||
use app\admin\model\Purchase; | |||
use think\Exception; | |||
class OrderItemDao | |||
{ | |||
/** | |||
* 新增、更新记录 | |||
* @param $param | |||
* @param $orderId | |||
* @return array|string | |||
*/ | |||
public function modify($param, $orderId) | |||
{ | |||
$itemInfo = $this->getItemInfo($param['item_id']); | |||
if (!$itemInfo['flag']){ | |||
return $itemInfo; | |||
} | |||
try{ | |||
//设置入参 | |||
$data = [ | |||
"order_id" => $orderId, | |||
//附加项目 | |||
"item_id"=>$itemInfo['data']['id'], | |||
"item_type"=>$itemInfo['data']['item_type'], | |||
"item_name"=>$itemInfo['data']['item_name'], | |||
"item_memo"=>$itemInfo['data']['item_memo'], | |||
"item_unit"=>$itemInfo['data']['item_unit'], | |||
"country_name" => $itemInfo['data']['country_name'], | |||
"province_name" => $itemInfo['data']['province_name'], | |||
"city_name" => $itemInfo['data']['city_name'], | |||
"detail_address" => $itemInfo['data']['detail_address'], | |||
//其他 | |||
"check_in_date" => $param['check_in_date'], | |||
"confirm_status" => $param['confirm_status'], | |||
"confirm_no" => $param['confirm_no'], | |||
"customer_name" => $param['customer_name'], | |||
"customer_comments" => $param['customer_comments'], | |||
"trade_order_number" => $param['trade_order_number'], | |||
"res_person" => $param['res_person'], | |||
"res_person_id" => $param['res_person_id'], | |||
"del_flag"=>0 | |||
]; | |||
$orderHotelModel = new OrderHotel(); | |||
if (empty($param['id'])) { | |||
$id = $orderHotelModel->insertGetId($data); | |||
return Util::returnArrSu($id); | |||
}else { | |||
$orderHotelModel->save($data,["id"=>$param['id']]); | |||
return Util::returnArrSu($param['id']); | |||
} | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("更新附加项目子订单失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 获取附加项目信息 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getItemInfo($id) | |||
{ | |||
try { | |||
$model = new CfItem(); | |||
$result = $model->where(["id" => $id])->find(); | |||
if ($result == null) { | |||
return Util::returnArrEr("获取附加项目信息失败" . $id); | |||
} | |||
return Util::returnArrSu($result); | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("获取附加项目信息失败" . $id); | |||
} | |||
} | |||
/** | |||
* 设置子订单金额 | |||
* @param int $subOrderId | |||
* @return array | |||
*/ | |||
public function setSubOrderAmount( int $subOrderId) { | |||
try{ | |||
$purchaseModel = new Purchase(); | |||
$purchaseList = $purchaseModel->where(["order_detail_id"=>$subOrderId,"del_flag"=>0])->select(); | |||
$cost = 0; | |||
$amount = 0; | |||
$count = 0; | |||
foreach ($purchaseList as $purchase) { | |||
$cost += $purchase['total_cost']; | |||
$amount += $purchase['total_price']; | |||
$count += $purchase['count']; | |||
} | |||
//更新数据 | |||
$oderItem = new OrderItem(); | |||
$oderItem->update(["total_price"=>$amount,"total_cost"=>$cost,"count"=>$count])->where(["id"=>$subOrderId]); | |||
return Util::returnArrSu(); | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("更新附加项目订单子表金额失败".$subOrderId); | |||
} | |||
} | |||
/** | |||
* 获取详情 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getInfoById($id) { | |||
try { | |||
$model = new OrderItem(); | |||
$result = $model->where(["id" => $id])->find(); | |||
if ($result == null) { | |||
return Util::returnArrEr("获取子订单信息失败" . $id); | |||
} | |||
return Util::returnArrSu($result); | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("获取子订单信息失败" . $id); | |||
} | |||
} | |||
/** | |||
* 删除记录 | |||
* @param $order_id | |||
*/ | |||
public function delete($order_id){ | |||
$model = new OrderItem(); | |||
$model->save(["del_flag"=>1],["order_id"=>$order_id]); | |||
} | |||
/** | |||
* 删除记录 | |||
* @param $id | |||
*/ | |||
public function delById($id) { | |||
$model = new OrderItem(); | |||
$model->save(["del_flag"=>1],["id"=>$id]); | |||
} | |||
/** | |||
* 获取附加项目子订单列表 | |||
* @param $orderId | |||
* @return array | |||
*/ | |||
public function getListByOrderId($orderId){ | |||
$subOrderModel = new OrderItem(); | |||
try { | |||
$subOrderList = $subOrderModel->where(["order_id" => $orderId, "del_flag" => 0])->select(); | |||
if (null == $subOrderList) { | |||
return Util::returnArrEr([]); | |||
} | |||
return Util::returnArrSu($subOrderList); | |||
}catch (Exception $e) { | |||
return Util::returnArrEr("获取附加项目订单列表异常".$e->getMessage()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,128 @@ | |||
<?php | |||
/** | |||
* Created by PhpStorm. | |||
* User: nizongfeng | |||
* Date: 2021/10/27 | |||
* Time: 11:26 | |||
*/ | |||
namespace app\admin\service; | |||
use app\admin\command\Util; | |||
use app\admin\model\OrderHotel; | |||
use app\admin\model\OrderItem; | |||
use app\admin\model\OrderMain; | |||
use think\Exception; | |||
class OrderMainDao | |||
{ | |||
/** | |||
* 添加、更新订单信息 | |||
* @param $param | |||
* @return array | |||
*/ | |||
public function save($param) { | |||
try{ | |||
$data = [ | |||
"commissioner_id"=>$param['commissioner_id'], | |||
"commissioner"=>$param["commissioner"], | |||
"channel_id"=>$param["channel_id"], | |||
"channel_name"=>$param["channel_name"], | |||
"channel_order_no"=>$param["channel_order_no"], | |||
"user_name"=>$param["user_name"], | |||
"user_phone"=>$param["user_phone"], | |||
"order_memo"=>$param["order_memo"] | |||
]; | |||
$orderMain = new OrderMain(); | |||
if (empty($param['id'])) { | |||
$id = $orderMain->insertGetId($data); | |||
return Util::returnArrSu($id); | |||
} else { | |||
$orderMain->save($data,['id'=>$param['id']]); | |||
return Util::returnArrSu($param['id']); | |||
} | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("更新主订单失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 设置主订单金额 | |||
* @param int $orderId | |||
* @return array | |||
*/ | |||
public function setOrderAmount(int $orderId){ | |||
try { | |||
$itemModel = new OrderItem(); | |||
$hotelModel = new OrderHotel(); | |||
$itemList = $itemModel->where(["order_id" => $orderId])->select(); | |||
$hotelList = $hotelModel->where(["order_id" => $orderId])->select(); | |||
$amount = 0; | |||
$cost = 0; | |||
foreach ($itemList as $item) { | |||
$amount += $item['total_price']; | |||
$cost += $item['total_cost']; | |||
} | |||
foreach ($hotelList as $hotel) { | |||
$amount += $hotel['total_price']; | |||
$cost += $hotel["total_cost"]; | |||
} | |||
//更新金额 | |||
OrderMain::update(["total_amount" => $amount, "cost_amount" => $cost])->where(["id" => $orderId]); | |||
return Util::returnArrSu(); | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("更新主表订单金额失败".$orderId); | |||
} | |||
} | |||
/** | |||
* 根据ID获取详情 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function getInfoById($id) { | |||
try { | |||
$orderMainModel = new OrderMain(); | |||
$orderMain = $orderMainModel->where(["id" => $id])->find(); | |||
if (null == $orderMain) { | |||
return Util::returnArrEr("订单查询失败".$id); | |||
} | |||
return Util::returnArrSu($orderMain); | |||
}catch (Exception $e) { | |||
return Util::returnArrEr("订单查询失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 子订单展示 | |||
* @param $purchaseShow | |||
* @param $orderHotel | |||
* @param $orderItem | |||
* @return array | |||
*/ | |||
public function setSubOrderShow($purchaseShow,$orderHotel,$orderItem){ | |||
$result = []; | |||
foreach ($orderItem as $item) { | |||
$item['prod_type'] = 'item'; | |||
foreach ($purchaseShow as $key=> $purchase) { | |||
if ($item['id'] == $key) { | |||
array_merge($item,$purchase); | |||
} | |||
} | |||
$result[] = $item; | |||
} | |||
foreach ($orderHotel as $hotel) { | |||
$hotel['prod_type'] = 'hotel'; | |||
foreach ($purchaseShow as $key=> $purchase) { | |||
if ($hotel['id'] == $key) { | |||
array_merge($hotel,$purchase); | |||
} | |||
} | |||
$result[] = $hotel; | |||
} | |||
return Util::returnArrSu($result); | |||
} | |||
} |
@@ -1,11 +1,15 @@ | |||
<?php | |||
namespace app\admin\service; | |||
use app\admin\command\Util; | |||
use app\admin\model\OrderHotel; | |||
use app\admin\model\OrderItem; | |||
use app\admin\model\OrderMain; | |||
use app\admin\model\Purchase; | |||
use app\admin\model\PurchasePrice; | |||
use think\Exception; | |||
use think\Url; | |||
/** | |||
* Created by PhpStorm. | |||
@@ -13,77 +17,243 @@ use app\admin\model\PurchasePrice; | |||
* Date: 2021/10/24 | |||
* Time: 15:55 | |||
*/ | |||
class OrderMainService | |||
{ | |||
/** | |||
* 设置主订单金额 | |||
* @param int $orderId | |||
* @throws | |||
* 保存主订单 | |||
* @param $param | |||
* @return array | |||
*/ | |||
private static function setOrderAmount(int $orderId){ | |||
$itemModel = new OrderItem(); | |||
$hotelModel = new OrderHotel(); | |||
$itemList =$itemModel->where(["order_id"=>$orderId])->select()->toArray(); | |||
$hotelList = $hotelModel->where(["order_id"=>$orderId])->select()->toArray(); | |||
$amount = 0; | |||
$cost = 0; | |||
foreach ($itemList as $item) { | |||
$amount += $item['total_price']; | |||
$cost+= $item['total_cost']; | |||
} | |||
foreach ($hotelList as $hotel) { | |||
$amount += $hotel['total_price']; | |||
$cost += $hotel["total_cost"]; | |||
} | |||
//更新金额 | |||
OrderMain::update(["total_amount"=>$amount,"cost_amount"=>$cost])->where(["id"=>$orderId]); | |||
public function saveOrder($param) | |||
{ | |||
/** | |||
* 1.添加主订单 | |||
*/ | |||
$orderMainDao = new OrderMainDao(); | |||
$addOrderMain = $orderMainDao->save($param); | |||
if (!$addOrderMain["flag"]) { | |||
return $addOrderMain; | |||
} | |||
$orderId = $addOrderMain['data']; | |||
//所有子订单设置为删除 | |||
$orderHotelDao = new OrderHotelDao(); | |||
$orderHotelDao->delete($orderId); | |||
$orderItemDao = new OrderItemDao(); | |||
$orderItemDao->delete($orderId); | |||
$purchasePriceDao = new PurchasePriceDao(); | |||
$purchasePriceDao->delete($orderId); | |||
//循环子订单 | |||
foreach ($param['subOrderList'] as $subOrderParam) { | |||
/** | |||
* 2.添加子订单 有则激活更新、无则添加 | |||
*/ | |||
if ($subOrderParam['prodType'] == 'hotel') { | |||
$subOrderDao = $orderHotelDao; | |||
} else { | |||
$subOrderDao = $orderItemDao; | |||
} | |||
$addSubOrder = $subOrderDao->modify($subOrderParam, $orderId); | |||
if (!$addSubOrder['flag']) { | |||
return $addSubOrder; | |||
} | |||
$subOrderId = $addSubOrder['data']; | |||
$subOrderInfo = $subOrderDao->getInfoById($subOrderId); | |||
/** | |||
* 2.1添加子订单下的采购单 有则更新激活、无则添加 | |||
*/ | |||
$purchaseDao = new PurchaseDao(); | |||
if ($subOrderParam['prod_type'] == 'hotel') { | |||
$addPurchase = $purchaseDao->saveHotelPurchase($subOrderParam, $subOrderInfo); | |||
} else { | |||
$addPurchase = $purchaseDao->saveItemPurchase($subOrderParam, $subOrderInfo); | |||
} | |||
if (!$addPurchase['flag']) { | |||
return $addPurchase; | |||
} | |||
$purchaseId = $addPurchase['id']; | |||
/** | |||
* 2.1.1添加采购单的每日价格 先删除、后添加激活 | |||
*/ | |||
$purchasePriceDao = new PurchasePriceDao(); | |||
$addPurchasePrice = $purchasePriceDao->saveList($subOrderParam['purchasePriceList'], $orderId, $subOrderParam['prod_type'], $subOrderId, $purchaseId); | |||
if (!$addPurchasePrice['flag']) { | |||
return $addPurchasePrice; | |||
} | |||
/** | |||
* 2.1.2 计算更新 采购单总金额、成本、产品数量 | |||
*/ | |||
$setPurchaseRe = $purchaseDao->setPurchaseAmount($purchaseId); | |||
if (!$setPurchaseRe['flag']) { | |||
return $setPurchaseRe; | |||
} | |||
/** | |||
* 2.2 计算更新 子订单成本、金额、产品数量 | |||
*/ | |||
$setSubOrderRe = $subOrderDao->setSubOrderAmount($subOrderId); | |||
if (!$setSubOrderRe['flag']) { | |||
return $setSubOrderRe; | |||
} | |||
} | |||
/** | |||
* 3 计算更新 主订单成本、金额、产品数量 | |||
*/ | |||
$setOrderMainRe = $orderMainDao->setOrderAmount($orderId); | |||
if (!$setOrderMainRe['flag']) { | |||
return $setOrderMainRe; | |||
} | |||
return Util::returnArrSu($orderId); | |||
} | |||
/** | |||
* 设置子订单金额 | |||
* @param int $subOrderId | |||
* @param string $prodType | |||
* @throws \think\db\exception\DataNotFoundException | |||
* @throws \think\db\exception\ModelNotFoundException | |||
* @throws \think\exception\DbException | |||
* 保存子订单 | |||
* @param $subOrderParam | |||
* @return array | |||
*/ | |||
private static function setSubOrderAmount( int $subOrderId,string $prodType) { | |||
$purchaseModel = new Purchase(); | |||
$purchaseList = $purchaseModel->where(["order_detail_id"=>$subOrderId,"del_flag"=>0])->select()->toArray(); | |||
$cost = 0; | |||
$amount = 0; | |||
foreach ($purchaseList as $purchase) { | |||
$cost += $purchase['total_cost']; | |||
$amount += $purchase['total_price']; | |||
} | |||
if ($prodType == "hotel") { | |||
OrderHotel::update(["total_price"=>$amount,"total_cost"=>$cost])->where(["id"=>$subOrderId]); | |||
public function subOrderSave($subOrderParam) | |||
{ | |||
$orderId = $subOrderParam['order_id']; | |||
$orderMainDao = new OrderMainDao(); | |||
/** | |||
* 2.添加子订单 | |||
*/ | |||
if ($subOrderParam['prodType'] == 'hotel') { | |||
$subOrderDao = new OrderHotelDao(); | |||
} else { | |||
OrderItem::update(["total_price"=>$amount,"total_cost"=>$cost])->where(["id"=>$subOrderId]); | |||
$subOrderDao = new OrderItemDao(); | |||
} | |||
$addSubOrder = $subOrderDao->modify($subOrderParam, $orderId); | |||
if (!$addSubOrder['flag']) { | |||
return $addSubOrder; | |||
} | |||
$subOrderId = $addSubOrder['data']; | |||
$subOrderInfo = $subOrderDao->getInfoById($subOrderId); | |||
/** | |||
* 2.1添加子订单下的采购单 | |||
*/ | |||
$purchaseDao = new PurchaseDao(); | |||
if ($subOrderParam['prod_type'] == 'hotel') { | |||
$addPurchase = $purchaseDao->saveHotelPurchase($subOrderParam, $subOrderInfo); | |||
} else { | |||
$addPurchase = $purchaseDao->saveItemPurchase($subOrderParam, $subOrderInfo); | |||
} | |||
if (!$addPurchase['flag']) { | |||
return $addPurchase; | |||
} | |||
$purchaseId = $addPurchase['id']; | |||
/** | |||
* 2.1.1添加采购单的每日价格 | |||
*/ | |||
$purchasePriceDao = new PurchasePriceDao(); | |||
$addPurchasePrice = $purchasePriceDao->saveList($subOrderParam['purchasePriceList'], $orderId, $subOrderParam['prod_type'], $subOrderId, $purchaseId); | |||
if (!$addPurchasePrice['flag']) { | |||
return $addPurchasePrice; | |||
} | |||
/** | |||
* 2.1.2 计算更新 采购单总金额、成本、产品数量 | |||
*/ | |||
$setPurchaseRe = $purchaseDao->setPurchaseAmount($purchaseId); | |||
if (!$setPurchaseRe['flag']) { | |||
return $setPurchaseRe; | |||
} | |||
/** | |||
* 2.2 计算更新 子订单成本、金额、产品数量 | |||
*/ | |||
$setSubOrderRe = $subOrderDao->setSubOrderAmount($subOrderId); | |||
if (!$setSubOrderRe['flag']) { | |||
return $setSubOrderRe; | |||
} | |||
/** | |||
* 3 计算更新 主订单成本、金额、产品数量 | |||
*/ | |||
$setOrderMainRe = $orderMainDao->setOrderAmount($orderId); | |||
if (!$setOrderMainRe['flag']) { | |||
return $setOrderMainRe; | |||
} | |||
return Util::returnArrSu($subOrderId); | |||
} | |||
/** | |||
* 删除子订单 | |||
* @param $param | |||
* @return array | |||
*/ | |||
public function delSubOrder($param){ | |||
try { | |||
if ($param['prodType'] == 'hotel') { | |||
$subOrderDao = new OrderHotelDao(); | |||
} else { | |||
$subOrderDao = new OrderItemDao(); | |||
} | |||
$subOrderDao->delById($param['id']); | |||
//删除采购单 | |||
$purchaseDao = new PurchaseDao(); | |||
$purchaseDao->deleteBySubOrderId($param['id']); | |||
//删除每日采购单价格 | |||
$purchasePriceDao = new PurchasePriceDao(); | |||
$purchasePriceDao->deleteBySubOrderId($param['id']); | |||
return Util::returnArrSu(); | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("删除子订单失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 设置采购单/子订单/主订单 金额 | |||
* @param Purchase $purchase | |||
* @throws \think\db\exception\DataNotFoundException | |||
* @throws \think\db\exception\ModelNotFoundException | |||
* @throws \think\exception\DbException | |||
* 获取订单详情 | |||
* @param $id | |||
* @return array | |||
*/ | |||
public function setPurchase(Purchase $purchase){ | |||
$purchasePrice = new PurchasePrice(); | |||
$purchasePriceList = $purchasePrice->where(["purchase_id"=>$purchase["id"],"del_flag"=>0])->select()->toArray(); | |||
$cost = 0; | |||
$amount = 0; | |||
foreach ($purchasePriceList as $price) { | |||
$cost += $price['cost'] * $price["cnt"]; | |||
$amount += $price['price'] * $price["cnt"]; | |||
} | |||
Purchase::update(["total_price"=>$amount,["total_cost"=>$cost]])->where(["id"=>$purchase['id']]); | |||
//更新子表 | |||
static::setSubOrderAmount($purchase['order_detail_id'], $purchase['prod_type']); | |||
//更新主表金额 | |||
static::setOrderAmount($purchase['order_id']); | |||
public function getOrderInfo($id){ | |||
$orderMainDao = new OrderMainDao(); | |||
$orderMainRe = $orderMainDao->getInfoById($id); | |||
if (!$orderMainRe['flag']) { | |||
return $orderMainRe; | |||
} | |||
$orderMain = $orderMainRe['data']; | |||
//获取采购单金额列表 | |||
$purchasePriceDao = new PurchasePriceDao(); | |||
$purchasePriceRe = $purchasePriceDao->getPurchasePriceListByOrderId($id); | |||
if (!$purchasePriceRe['flag']) { | |||
return $purchasePriceRe; | |||
} | |||
//获取采购单列表 | |||
$purchaseDao = new PurchaseDao(); | |||
$purchaseRe = $purchaseDao->getListByOrderId($id); | |||
if (!$purchaseRe['flag']) { | |||
return $purchaseRe; | |||
} | |||
//设置采购单展示数据 | |||
$purchaseShow = $purchaseDao->setPurchaseShow($purchaseRe['data'],$purchasePriceRe['data']); | |||
if (!$purchaseShow['flag']) { | |||
return $purchaseShow; | |||
} | |||
//获取子订单列表 | |||
$orderHotelDao = new OrderHotelDao(); | |||
$orderHotelRe = $orderHotelDao->getListByOrderId($id); | |||
if (!$orderHotelRe['flag']) { | |||
return $orderHotelRe; | |||
} | |||
$orderItemDao = new OrderItemDao(); | |||
$orderItemRe = $orderItemDao->getListByOrderId($id); | |||
if (!$orderItemRe['flag']) { | |||
return $orderItemRe; | |||
} | |||
//设置子订单列表 | |||
$subOrderList = $orderMainDao->setSubOrderShow($purchaseShow['data'],$orderHotelRe['data'],$orderItemRe['data']); | |||
if (!$subOrderList['flag']) { | |||
return $subOrderList; | |||
} | |||
$orderMain["subOrderList"]=$subOrderList['data']; | |||
return Util::returnArrSu($orderMain); | |||
} | |||
} |
@@ -0,0 +1,190 @@ | |||
<?php | |||
/** | |||
* Created by PhpStorm. | |||
* User: nizongfeng | |||
* Date: 2021/10/27 | |||
* Time: 16:38 | |||
*/ | |||
namespace app\admin\service; | |||
use app\admin\command\Util; | |||
use app\admin\model\Purchase; | |||
use app\admin\model\PurchasePrice; | |||
use think\Exception; | |||
class PurchaseDao | |||
{ | |||
/** | |||
* 添加酒店项目采购单 | |||
* @param $param | |||
* @param $hotelOrder | |||
* @return array | |||
*/ | |||
public function saveHotelPurchase($param,$hotelOrder):array { | |||
try { | |||
$data = [ | |||
"order_id" => $hotelOrder['order_id'], | |||
"prod_type" => 'hotel', | |||
"order_detail_id" => $hotelOrder['id'], | |||
"group_id" => $param['group_id'], | |||
"pro_name" => $hotelOrder['hotel_name'], | |||
"item_name" => $hotelOrder['room_name'], | |||
"item_unit" => $hotelOrder['plan_name'], | |||
"check_in_date" => $param['check_in_date'], | |||
"check_out_date" => $param['check_out_date'], | |||
"supplier_id" => $param['supplier_id'], | |||
"supplier_name" => $param['supplier_name'], | |||
"purchase_user_id" => $param['purchase_user_id'], | |||
"purchase_user" => $param['purchase_user'], | |||
"del_flag"=>0 | |||
]; | |||
$model = new Purchase(); | |||
if (empty($param['purchase_id'])) { | |||
$id = $model->insertGetId($data); | |||
return Util::returnArrSu($id); | |||
}else { | |||
$model->save($data,["id"=>$param['purchase_id']]); | |||
return Util::returnArrSu($param['purchase_id']); | |||
} | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("新增采购都失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 添加附加项目采购单 | |||
* @param $param | |||
* @param $itemOrder | |||
* @return array | |||
*/ | |||
public function saveItemPurchase($param, $itemOrder):array { | |||
try { | |||
$data = [ | |||
"order_id" => $itemOrder['order_id'], | |||
"prod_type" => 'hotel', | |||
"order_detail_id" => $itemOrder['id'], | |||
"group_id" => $param['group_id'], | |||
"pro_name" => $itemOrder['hotel_name'], | |||
"item_name" => $itemOrder['item_name'], | |||
"item_unit" => $itemOrder['item_unit'], | |||
"check_in_date" => $param['check_in_date'], | |||
"check_out_date" => $param['check_out_date'], | |||
"supplier_id" => $param['supplier_id'], | |||
"supplier_name" => $param['supplier_name'], | |||
"purchase_user_id" => $param['purchase_user_id'], | |||
"purchase_user" => $param['purchase_user'], | |||
"del_flag"=>0 | |||
]; | |||
$model = new Purchase(); | |||
if (empty($param['purchase_id'])) { | |||
$id = $model->insertGetId($data); | |||
return Util::returnArrSu($id); | |||
}else { | |||
$model->save($data,["id"=>$param['purchase_id']]); | |||
return Util::returnArrSu($param['purchase_id']); | |||
} | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("新增采购都失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 设置采购单 金额 | |||
* @param $purchaseId | |||
* @return array | |||
*/ | |||
public function setPurchaseAmount(int $purchaseId){ | |||
try{ | |||
$purchasePrice = new PurchasePrice(); | |||
$purchasePriceList = $purchasePrice->where(["purchase_id"=>$purchaseId,"del_flag"=>0])->select()->toArray(); | |||
$cost = 0; | |||
$amount = 0; | |||
$cnt = 0; | |||
foreach ($purchasePriceList as $price) { | |||
$cost += $price['cost'] * $price["cnt"]; | |||
$amount += $price['price'] * $price["cnt"]; | |||
$cnt += $price['cnt']; | |||
} | |||
Purchase::update(["total_price"=>$amount,"total_cost"=>$cost,"count"=>$cnt])->where(["id"=>$purchaseId]); | |||
return Util::returnArrSu(); | |||
}catch (Exception $e){ | |||
return Util::returnArrEr("更新采购单金额失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 删除记录 | |||
* @param $order_id | |||
*/ | |||
public function delete($order_id){ | |||
$model = new Purchase(); | |||
$model->save(["del_flag"=>1],["order_id"=>$order_id]); | |||
} | |||
/** | |||
* 删除子订单 | |||
* @param $subOrderId | |||
*/ | |||
public function deleteBySubOrderId($subOrderId) { | |||
$model = new Purchase(); | |||
$model->save(["del_flag"=>1],["order_detail_id"=>$subOrderId]); | |||
} | |||
/** | |||
* 获取采购单列表 | |||
* @param $orderId | |||
* @return array | |||
*/ | |||
public function getListByOrderId($orderId) { | |||
$model = new Purchase(); | |||
try { | |||
$list = $model->where(["order_id" => $orderId, "del_flag" => 0])->select(); | |||
if (null == $list) { | |||
return Util::returnArrSu([]); | |||
} | |||
return Util::returnArrSu($list); | |||
}catch (Exception $e) { | |||
return Util::returnArrEr("获取订单的采购单列表失败".$e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 设置 | |||
* @param $purchaseList | |||
* @param $purchasePriceList | |||
* @return array | |||
*/ | |||
public function setPurchaseShow($purchaseList,$purchasePriceList){ | |||
$result = []; | |||
foreach ($purchaseList as $purchase) { | |||
$purchaseShow=[ | |||
"purchase_id"=>$purchase['id'], | |||
"purchase_user_id"=>$purchase['purchase_user_id'], | |||
"purchase_user"=>$purchase['purchase_user'], | |||
"supplier_id"=>$purchase['supplier_id'], | |||
"supplier_name" =>$purchase['supplier_name'], | |||
"purchasePriceList"=>[] | |||
]; | |||
foreach ($purchasePriceList as $price) { | |||
if ($price['purchase_id'] == $purchase['id']) { | |||
$priceShow = [ | |||
"id"=>$price['id'], | |||
"run_date"=>$price['run_date'], | |||
"count"=>$price['count'], | |||
"price"=>$price['price'], | |||
"cost"=>$price['cost'] | |||
]; | |||
$purchaseShow["purchasePriceList"][]=$priceShow; | |||
} | |||
} | |||
if (null == $result[$purchase['order_detail_id']]) { | |||
$result[$purchase['order_detail_id']] = []; | |||
} | |||
$result[$purchase['order_detail_id']][]= $purchaseShow; | |||
} | |||
return Util::returnArrSu($result); | |||
} | |||
} |
@@ -0,0 +1,95 @@ | |||
<?php | |||
/** | |||
* Created by PhpStorm. | |||
* User: nizongfeng | |||
* Date: 2021/10/27 | |||
* Time: 19:19 | |||
*/ | |||
namespace app\admin\service; | |||
use app\admin\command\Util; | |||
use app\admin\model\PurchasePrice; | |||
use think\Exception; | |||
class PurchasePriceDao | |||
{ | |||
/** | |||
* 添加采购单每日价格 | |||
* @param $param | |||
* @param int $order_id | |||
* @param string $prod_type | |||
* @param int $order_detail_id | |||
* @param int $purchase_id | |||
* @return array | |||
*/ | |||
public function saveList($param, int $order_id, string $prod_type, int $order_detail_id, int $purchase_id) | |||
{ | |||
try { | |||
//删除记录 | |||
$this->delete($order_detail_id); | |||
//循环添加 | |||
foreach ($param as $value) { | |||
$data = [ | |||
"order_id" => $order_id, | |||
"prod_type" => $prod_type, | |||
"order_detail_id" => $order_detail_id, | |||
"purchase_id" => $purchase_id, | |||
"run_date" => $value['run_date'], | |||
"count" => $value['count'], | |||
"price" => $value['price'], | |||
"cost" => $value['cost'], | |||
"del_flag" => 0 | |||
]; | |||
$model = new PurchasePrice(); | |||
if (empty($value['id'])) { | |||
$model->insertGetId($data); | |||
} else { | |||
$model->save($data, ["id" => $value['id']]); | |||
} | |||
} | |||
return Util::returnArrSu(); | |||
} catch (Exception $e) { | |||
return Util::returnArrEr("添加/更新采购单每日价格失败" . $e->getMessage()); | |||
} | |||
} | |||
/** | |||
* 删除数据 | |||
* @param $purchase_id | |||
*/ | |||
public function delete($purchase_id) | |||
{ | |||
$model = new PurchasePrice(); | |||
$model->save(["del_flag" => 1], ["purchase_id" => $purchase_id]); | |||
} | |||
/** | |||
* 删除子订单对于的每日价格 | |||
* @param $subOrderId | |||
*/ | |||
public function deleteBySubOrderId($subOrderId) { | |||
$model = new PurchasePrice(); | |||
$model->save(["del_flag" => 1], ["order_detail_id" => $subOrderId]); | |||
} | |||
/** | |||
* 获取采购单金额 | |||
* @param $orderId | |||
* @return array | |||
*/ | |||
public function getPurchasePriceListByOrderId($orderId) { | |||
$model = new PurchasePrice(); | |||
try { | |||
$list = $model->where(["order_id" => $orderId, "del_flag" => $orderId])->select(); | |||
if (null == $list) { | |||
return Util::returnArrSu([]); | |||
} | |||
return Util::returnArrSu($list); | |||
}catch (Exception $e) { | |||
return Util::returnArrEr("获取采购单金额异常".$e->getMessage()); | |||
} | |||
} | |||
} |
@@ -109,9 +109,9 @@ | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Total_cose')}:</label> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Total_cost')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-total_cose" data-rule="required" class="form-control" step="0.01" name="row[total_cose]" type="number" value="0.00"> | |||
<input id="c-total_cost" data-rule="required" class="form-control" step="0.01" name="row[total_cost]" type="number" value="0.00"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -109,9 +109,9 @@ | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Total_cose')}:</label> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Total_cost')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-total_cose" data-rule="required" class="form-control" step="0.01" name="row[total_cose]" type="number" value="{$row.total_cose|htmlentities}"> | |||
<input id="c-total_cost" data-rule="required" class="form-control" step="0.01" name="row[total_cost]" type="number" value="{$row.total_cost|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -55,9 +55,9 @@ | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Total_cose')}:</label> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Total_cost')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-total_cose" data-rule="required" class="form-control" step="0.01" name="row[total_cose]" type="number" value="0.00"> | |||
<input id="c-total_cost" data-rule="required" class="form-control" step="0.01" name="row[total_cost]" type="number" value="0.00"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -55,9 +55,9 @@ | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Total_cose')}:</label> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Total_cost')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-total_cose" data-rule="required" class="form-control" step="0.01" name="row[total_cose]" type="number" value="{$row.total_cose|htmlentities}"> | |||
<input id="c-total_cost" data-rule="required" class="form-control" step="0.01" name="row[total_cost]" type="number" value="{$row.total_cost|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -1 +1,4 @@ | |||
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>single</title><link href=/static/css/app.dd52211446ddd52c52e583d315f1b8eb.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.2a7a823a51f8e30ff8b3.js></script><script type=text/javascript src=/static/js/app.157d167cfbe409b5fcfd.js></script></body></html> | |||
<script> | |||
window.type = 'add' | |||
</script> | |||
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>single</title><link href=/static/css/app.96d8ca953119e6bf3089010d0b52faac.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.d74fe6c76e290fa6381b.js></script><script type=text/javascript src=/static/js/app.54bea408cdbd8067836f.js></script></body></html> |
@@ -1,118 +1,4 @@ | |||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Create_user_id')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-create_user_id" data-rule="required" data-source="create/user/index" class="form-control selectpage" name="row[create_user_id]" type="text" value="{$row.create_user_id|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Group_id')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-group_id" data-rule="required" data-source="group/index" class="form-control selectpage" name="row[group_id]" type="text" value="{$row.group_id|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Commissioner')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-commissioner" data-rule="required" class="form-control" name="row[commissioner]" type="text" value="{$row.commissioner|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Channel_id')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-channel_id" data-rule="required" data-source="channel/index" class="form-control selectpage" name="row[channel_id]" type="text" value="{$row.channel_id|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Channel_order_no')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-channel_order_no" data-rule="required" class="form-control" name="row[channel_order_no]" type="text" value="{$row.channel_order_no|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('User_name')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-user_name" data-rule="required" class="form-control" name="row[user_name]" type="text" value="{$row.user_name|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('User_phone')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-user_phone" data-rule="required" class="form-control" name="row[user_phone]" type="text" value="{$row.user_phone|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Total_amount')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-total_amount" data-rule="required" class="form-control" step="0.01" name="row[total_amount]" type="number" value="{$row.total_amount|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Cost_amount')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-cost_amount" data-rule="required" class="form-control" step="0.01" name="row[cost_amount]" type="number" value="{$row.cost_amount|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Profit_amount')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-profit_amount" data-rule="required" class="form-control" step="0.01" name="row[profit_amount]" type="number" value="{$row.profit_amount|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Order_status')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-order_status" data-rule="required" class="form-control" name="row[order_status]" type="number" value="{$row.order_status|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Order_memo')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-order_memo" data-rule="required" class="form-control" name="row[order_memo]" type="text" value="{$row.order_memo|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Log')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-log" data-rule="required" class="form-control" name="row[log]" type="text" value="{$row.log|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Cancel_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-cancel_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[cancel_time]" type="text" value="{:$row.cancel_time?datetime($row.cancel_time):''}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Success_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-success_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[success_time]" type="text" value="{:$row.success_time?datetime($row.success_time):''}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Del_flag')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-del_flag" data-rule="required" class="form-control" name="row[del_flag]" type="number" value="{$row.del_flag|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-create_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:$row.create_time?datetime($row.create_time):''}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Update_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-update_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{:$row.update_time?datetime($row.update_time):''}"> | |||
</div> | |||
</div> | |||
<div class="form-group layer-footer"> | |||
<label class="control-label col-xs-12 col-sm-2"></label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> | |||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | |||
</div> | |||
</div> | |||
</form> | |||
<script> | |||
window.type = 'edit' | |||
</script> | |||
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>single</title><link href=/static/css/app.96d8ca953119e6bf3089010d0b52faac.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script><script type=text/javascript src=/static/js/vendor.d74fe6c76e290fa6381b.js></script><script type=text/javascript src=/static/js/app.54bea408cdbd8067836f.js></script></body></html> |
@@ -44,7 +44,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | |||
{field: 'check_out_date', title: __('Check_out_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, | |||
{field: 'prod_num', title: __('Prod_num')}, | |||
{field: 'total_price', title: __('Total_price'), operate:'BETWEEN'}, | |||
{field: 'total_cose', title: __('Total_cose'), operate:'BETWEEN'}, | |||
{field: 'total_cost', title: __('Total_cost'), operate:'BETWEEN'}, | |||
{field: 'profit', title: __('Profit'), operate:'BETWEEN'}, | |||
{field: 'log', title: __('Log'), operate: 'LIKE'}, | |||
{field: 'del_flag', title: __('Del_flag'), formatter: Table.api.formatter.flag}, | |||
@@ -35,7 +35,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | |||
{field: 'use_date', title: __('Use_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, | |||
{field: 'prod_num', title: __('Prod_num')}, | |||
{field: 'total_price', title: __('Total_price'), operate: 'LIKE'}, | |||
{field: 'total_cose', title: __('Total_cose'), operate:'BETWEEN'}, | |||
{field: 'total_cost', title: __('Total_cost'), operate:'BETWEEN'}, | |||
{field: 'profit', title: __('Profit'), operate:'BETWEEN'}, | |||
{field: 'log', title: __('Log'), operate: 'LIKE'}, | |||
{field: 'country_name', title: __('Country_name'), operate: 'LIKE'}, | |||