Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

498 řádky
24 KiB

  1. <?php
  2. /**
  3. *
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 温依莅
  12. * PhpStorm DynamicBus.php 动态巴士 票种,班次,订单生成
  13. * Create By 2017/7/19 15:00 $
  14. */
  15. namespace backend\modules\api\logic;
  16. use backend\modules\api\models\BaseUser;
  17. use backend\modules\api\models\OperaTickets;
  18. use backend\modules\api\models\OperaTicketsGroup;
  19. use backend\modules\api\models\OperaLine;
  20. use backend\modules\api\models\RunMain;
  21. use backend\modules\api\models\RunProd;
  22. use backend\modules\api\models\RunStation;
  23. use backend\modules\api\models\OperaStation;
  24. use backend\modules\api\models\BaseTailorStation;
  25. use common\models\Msg;
  26. use yii\db\Query;
  27. use yii\base\Exception;
  28. use yii\db\Expression;
  29. use Yii;
  30. /**
  31. * 动态巴士
  32. */
  33. class DynamicBus extends Query
  34. {
  35. /**
  36. * Function Description:生成动态巴士票种
  37. * Function Name: generateTickets
  38. * @param $line_id
  39. *
  40. * @return array
  41. *
  42. * @author 温依莅
  43. */
  44. public function generateTickets($line_id)
  45. {
  46. $result = array();
  47. //1,根据线路id,获取动态巴士产品信息
  48. $line_res = OperaLine::getDynamicInfo($line_id);
  49. if (!$line_res) {
  50. $result['code'] = '1';
  51. $result['info'] = '该动态巴士线路无效';
  52. return $result;
  53. }
  54. //2,根据线路站点(上下车)得到需要可添加的票种类型
  55. $station_res = OperaStation::getTicketsInfo($line_id);
  56. if (!$station_res) {
  57. $result['code'] = '1';
  58. $result['info'] = '该线路无站点信息';
  59. return $result;
  60. }
  61. $ticket_station = array();
  62. foreach ($station_res as $sk => $sv) {
  63. if ($sv['inout_type'] == 108 || $sv['inout_type'] == 109) {
  64. foreach ($station_res as $ek => $ev) {
  65. if (($ev['inout_type'] == 109 || $ev['inout_type'] == 110) && ($sv['order_id'] < $ev['order_id'])) {
  66. $arr['line_id'] = $ev['line_id'];
  67. $arr['start_res_id'] = $sv['res_id'];
  68. $arr['start_res_name'] = $sv['res_name'];
  69. $arr['start_area_id'] = $sv['area_id'];
  70. $arr['start_order_id'] = $sv['order_id'];
  71. $arr['start_inout_type'] = $sv['inout_type'];
  72. $arr['start_start_minutes'] = $sv['start_minutes'];
  73. $arr['end_res_id'] = $ev['res_id'];
  74. $arr['end_res_name'] = $ev['res_name'];
  75. $arr['end_area_id'] = $ev['area_id'];
  76. $arr['end_order_id'] = $ev['order_id'];
  77. $arr['end_inout_type'] = $ev['inout_type'];
  78. $arr['end_start_minutes'] = $ev['start_minutes'];
  79. $ticket_station[$sv['res_id'] . '-' . $ev['res_id']] = $arr;
  80. }
  81. }
  82. }
  83. }
  84. if (!$ticket_station) {
  85. $result['code'] = '1';
  86. $result['info'] = '该线路无法生成票种';
  87. return $result;
  88. }
  89. //3,判断opera_tickets表已有票种,根据票种上下车站点对要添加的票种做去重处理
  90. $existed_tickets = OperaTickets::getExistedTickets($line_id);
  91. $add_tickets = array();//需要添加的票种站点信息
  92. foreach ($ticket_station as $tk => $tv) {
  93. if (!isset($existed_tickets[$tk])) {
  94. $add_tickets[$tk] = $tv;
  95. }
  96. }
  97. if (empty($add_tickets)) {
  98. $result['code'] = '1';
  99. $result['info'] = '无需要添加票种';
  100. return $result;
  101. }
  102. //4,插入opera_tickets_group和opera_tickets
  103. #4.1部分准备数据
  104. $user_id = Yii::$app->request->cookies->getValue('user_id', 2);
  105. $time = date('Y-m-d H:i:s');
  106. $extra_arr = array('ticket_type' => 1, 'ticket_name' => '普通座票', 'seat_type' => 72, 'human_type' => 159);//部分票种默认信息
  107. #4.2插入数据
  108. $transaction = Yii::$app->db->beginTransaction();
  109. try {
  110. #4.2.1 先插入opera_tickets表
  111. $group_ticket_id = array();//添加的票种id集合
  112. $group_station_id = array();
  113. $group_station_name = array();
  114. foreach ($add_tickets as $k => $v) {
  115. $opera_tickets_one = [
  116. 'CREATE_USER_ID' => $user_id,
  117. 'CREATE_TIME' => $time,
  118. 'UPDATE_USER_ID' => $user_id,
  119. 'UPDATE_TIME' => $time,
  120. 'CANCEL_FLAG' => 0,
  121. 'LINE_ID' => $line_id,
  122. 'TICKET_NAME' => $extra_arr['ticket_name'],
  123. 'TICKET_TYPE' => $extra_arr['ticket_type'],
  124. 'START_STATION_RES_ID' => $v['start_res_id'],
  125. 'END_STATION_RES_ID' => $v['end_res_id'],
  126. 'START_STATION_AREA_ID' => $v['start_area_id'],
  127. 'END_STATION_AREA_ID' => $v['end_area_id'],
  128. 'SEAT_TYPE' => $extra_arr['seat_type'],
  129. 'HUMAN_TYPE' => $extra_arr['human_type'],
  130. 'PROD_PRICE' => $line_res['prod_price'],
  131. 'CUS_PRICE' => $line_res['cus_price'],
  132. 'COST_PRICE' => $line_res['cost_price'],
  133. 'IS_ONSALE' => 1,
  134. ];
  135. $new_ticket = new OperaTickets();
  136. $new_ticket->attributes = $opera_tickets_one;
  137. if (!$new_ticket->insert()) {
  138. throw new Exception(serialize($new_ticket->getErrors()));
  139. }
  140. $group_ticket_id[] = $new_ticket->TICKET_ID;
  141. $group_station_id[] = $v['start_res_id'] . '-' . $v['end_res_id'];
  142. $group_station_name[] = $v['start_res_name'] . '-' . $v['end_res_name'];
  143. }
  144. #4.2.2 再插入opera_tickets_group表
  145. $opera_tickets_group_arr = array(
  146. 'CREATE_USER_ID' => $user_id,
  147. 'CREATE_TIME' => $time,
  148. 'UPDATE_USER_ID' => $user_id,
  149. 'UPDATE_TIME' => $time,
  150. 'CANCEL_FLAG' => 0,
  151. 'LINE_ID' => $line_id,
  152. 'TICKET_ID' => implode(',', $group_ticket_id),
  153. 'STATION_ID' => implode(',', $group_station_id),
  154. 'STATION_NAME' => implode(',', $group_station_name),
  155. 'SEAT_TYPE' => $extra_arr['seat_type'],
  156. 'HUMAN_TYPE' => $extra_arr['human_type'],
  157. 'PROD_PRICE' => $line_res['prod_price'],
  158. 'CUS_PRICE' => $line_res['cus_price'],
  159. 'COST_PRICE' => $line_res['cost_price'],
  160. );
  161. $ticket_group_obj = new OperaTicketsGroup();
  162. $ticket_group_obj->attributes = $opera_tickets_group_arr;
  163. if (!$ticket_group_obj->insert()) {
  164. throw new Exception(serialize($ticket_group_obj->getErrors()));
  165. }
  166. } catch (Exception $e) {
  167. # 回滚事务
  168. $transaction->rollBack();
  169. $result['code'] = '1';
  170. $result['info'] = '动态巴士票种添加失败,原因:' . $e->getMessage();
  171. return $result;
  172. }
  173. $transaction->commit();
  174. $result['code'] = '0';
  175. $result['info'] = '动态巴士票种添加成功';
  176. $result['list'] = array('ticket_arr' => $group_ticket_id);
  177. return $result;
  178. }
  179. /**
  180. * Function Description:生成动态巴士班次
  181. * Function Name: generateRunInfo
  182. * @param int $line_id 线路id
  183. * @param string $start_time 班次出发时间
  184. * @return mixed
  185. *
  186. * @author 温依莅
  187. */
  188. public function generateRunInfo($line_id, $start_time)
  189. {
  190. $result = array();
  191. $user_id = Yii::$app->request->cookies->getValue('user_id', 2);
  192. //0,判断班次时间格式是否正确
  193. if (!preg_match('/^(0[0-9]|1[0-9]|2[0-3])\:(0[0-9]|[1-5][0-9])$/', $start_time)) {
  194. $result['code'] = '1';
  195. $result['info'] = '产品出发时间格式不正确';
  196. return $result;
  197. }
  198. //1,根据动态巴士线路id 获取班次添加相关参数
  199. $run_param = array(
  200. 'user_id' => $user_id,
  201. 'lineid' => $line_id,//线路id 448655
  202. 'starttime' => '', //2017-07-26 班次最早日期
  203. 'endtime' => '', //2017-07-29 班次最晚日期
  204. 'week' => '2345671', //星期限制
  205. 'allstation' => '', //{9092,0,108,0}{9300,10,108,0}{100437,60,110,0} //{站点res_id,分钟数[距离0点],上下类型[108只上109上下110只下114不停],0}
  206. 'allcar' => '', //{1126,1,156,288,628,477,188}{221,1,156,288,400,478,56} //{车型类型,数量,156可选157不可选,车品牌名,供应商,计价方式[477包车计价478车座计价],价格}
  207. 'allticket' => '', //{3249,100437,72,159,0}{3326,100437,72,159,0} //{开始地区id,结束地区id,座位类型,人群类型}
  208. 'sellday' => 7, //预售天数【无实际作用】
  209. );
  210. $run_extra_arr = array( //班次添加部分默认参数
  211. 'bus_brand' => 288, //车辆品牌 288 金龙
  212. 'supplier_id' => 628, //车辆供应商 628 恒栋
  213. 'bus_money' => 500, //包车价格 默认500
  214. 'bus_type_19' => 1126, //19座的base_resource.res_id
  215. 'bus_type_53' => 1004, //53座的base_resource.res_id
  216. 'count_type' => 477, //计价方式 dict_type.id 477包车计价,478车座计价
  217. 'seat_type' => 72, //座位类型 72普通座
  218. 'human_type' => 159 //人群属性 159成人
  219. );
  220. #1.1获取班次日期
  221. $run_date = BaseTailorStation::getDynamicRunDate($line_id);
  222. if (!$run_date) {
  223. $result['code'] = '1';
  224. $result['info'] = '该动态巴士线路无有效乘客';
  225. return $result;
  226. }
  227. $run_param['starttime'] = $run_date;
  228. $run_param['endtime'] = $run_date;
  229. #1.2获取【班次站点信息allstation】 和 【站点区域分组 allticket】
  230. $station_res = OperaStation::getTicketsInfo($line_id);
  231. if (!$station_res) {
  232. $result['code'] = '1';
  233. $result['info'] = '该线路无站点信息';
  234. return $result;
  235. }
  236. #1.2.1获取【站点参数allstation】
  237. $allstation = '';
  238. $base_minutes = ceil((strtotime($run_date . ' ' . $start_time . ':00') - strtotime($run_date)) / 60); //获取基准分钟数
  239. foreach ($station_res as $k => $v) {
  240. $allstation .= '{' . $v['res_id'] . ',' . ($v['start_minutes'] + $base_minutes) . ',' . $v['inout_type'] . ',' . '0' . '}';
  241. }
  242. $run_param['allstation'] = $allstation;
  243. #1.2.2获取【站点区域分组参数 allticket】
  244. $ticket_area = array();
  245. foreach ($station_res as $sk => $sv) {
  246. if ($sv['inout_type'] == 108 || $sv['inout_type'] == 109) {
  247. foreach ($station_res as $ek => $ev) {
  248. if (($ev['inout_type'] == 109 || $ev['inout_type'] == 110) && ($sv['order_id'] < $ev['order_id'])) {
  249. $arr['start_area_id'] = $sv['area_id']; //起始区域id
  250. $arr['end_area_id'] = $ev['area_id']; //结束区域id
  251. $arr['seat_type'] = $run_extra_arr['seat_type'];//座位类型
  252. $arr['human_type'] = $run_extra_arr['human_type'];//人群属性
  253. $ticket_area[$sv['area_id'] . '-' . $ev['area_id']] = $arr;
  254. }
  255. }
  256. }
  257. }
  258. if (!$ticket_area) {
  259. $result['code'] = '1';
  260. $result['info'] = '该线路无有效票种【上下车区域判定】';
  261. return $result;
  262. }
  263. foreach ($ticket_area as $k => $v) {
  264. $run_param['allticket'] .= '{' . $v['start_area_id'] . ',' . $v['end_area_id'] . ',' . $v['seat_type'] . ',' . $v['human_type'] . ',' . '0' . '}';
  265. }
  266. #1.3获取车次车信息【allcar:订单总人数小于19人派 19座恒栋包车500元,大于19人派53座的恒栋包车500元】
  267. #1.3.1从动态巴士用户信息表获取该线路的总人数
  268. $person_num = BaseTailorStation::getTotalNum($line_id);
  269. if (!$person_num) {
  270. $result['code'] = '1';
  271. $result['info'] = '该动态线路无有效用户';
  272. return $result;
  273. }
  274. #1.3.2根据人数生成车次的选用车辆信息
  275. if ($person_num > 53) {
  276. $result['code'] = '1';
  277. $result['info'] = '超过最大53人,请联系管理员';
  278. return $result;
  279. }
  280. if ($person_num <= 19) {
  281. $run_param['allcar'] = '{' . $run_extra_arr['bus_type_19'] . ',' . '1' . ',' . '156' . ',' . $run_extra_arr['bus_brand'] . ',' . $run_extra_arr['supplier_id'] . ',' . $run_extra_arr['count_type'] . ',' . $run_extra_arr['bus_money'] . '}';
  282. } else {
  283. $run_param['allcar'] = '{' . $run_extra_arr['bus_type_53'] . ',' . '1' . ',' . '156' . ',' . $run_extra_arr['bus_brand'] . ',' . $run_extra_arr['supplier_id'] . ',' . $run_extra_arr['count_type'] . ',' . $run_extra_arr['bus_money'] . '}';
  284. }
  285. //2,调用巴士班次添加接口添加班次
  286. $sql = 'call sp_bus_run_new_save_tailor(' . $run_param['user_id'] . ',' . $run_param['lineid'] . ',' . $run_param['starttime'] . ',' . $run_param['endtime'] . ',' . $run_param['week'] . ',' . $run_param['allstation'] . ',' . $run_param['allcar'] . ',' . $run_param['allticket'] . ',' . $run_param['sellday'] . ')';
  287. //$this->writeLog($sql, 'sp_bus_run_new_save');//写入log
  288. $pres_obj = Yii::$app->db->createCommand("call sp_bus_run_new_save_tailor(:para_user_id,:para_lineid,:para_starttime,:para_endtime,:para_week,:para_allstation,:para_allcar,:para_allticket,:para_sellday)")
  289. ->bindValues([
  290. ":para_user_id" => $run_param['user_id'] + 0,
  291. ":para_lineid" => $run_param['lineid'],
  292. ":para_starttime" => $run_param['starttime'],
  293. ":para_endtime" => $run_param['endtime'],
  294. ":para_week" => $run_param['week'],
  295. ":para_allstation" => $run_param['allstation'],
  296. ":para_allcar" => $run_param['allcar'],
  297. ":para_allticket" => $run_param['allticket'],
  298. ":para_sellday" => $run_param['sellday'],
  299. ]);
  300. $query_sql = $pres_obj->getRawSql();
  301. $this->writeLog($query_sql, 'sp_bus_run_new_save');//写入log
  302. $pres = $pres_obj->queryOne();
  303. if ($pres['errcode'] != 0) {
  304. $result['code'] = '1';
  305. $result['info'] = '添加班次失败【' . $pres['errinfo'] . '】';
  306. return $result;
  307. }
  308. $result['code'] = '0';
  309. $result['info'] = '动态巴士班次添加成功';
  310. $result['list'] = array('run_param' => $run_param);
  311. return $result;
  312. }
  313. /**
  314. * Function Description:生成动态巴士订单
  315. * Function Name: generateOrders
  316. * @param int $line_id 线路id
  317. * @param $start_time
  318. *
  319. * @return array
  320. *
  321. * @author 温依莅
  322. */
  323. public function generateOrders($line_id, $start_time)
  324. {
  325. $result = array();
  326. $user_id = Yii::$app->request->cookies->getValue('user_id', 2);
  327. $main_corp_id = BaseUser::getMainCorpId($user_id);
  328. if (!$main_corp_id) {
  329. $result['code'] = '1';
  330. $result['info'] = '当前用户运营主体有误';
  331. return $result;
  332. }
  333. //1,根据line_id和start_time获取下单需要参数
  334. $order_extra_arr = array( //订单生成部分参数
  335. 'user_id' => $user_id, //用户id
  336. 'member_id' => $user_id, //会员id
  337. 'order_book_status' => 0, //是否是预定 1是0否
  338. 'pay_type' => 275, //支付方式 275 授信支付
  339. 'customer_id_type' => 150, //证件类型 150身份证
  340. 'order_pay_status' => 1, //支付状态 1已支付 0待支付
  341. 'is_send_msg' => 1, // 是否发送短信 1是0否
  342. 'sale_man' => '', // 业务员
  343. );
  344. #1.1获取该班次run_id
  345. $run_date = BaseTailorStation::getDynamicRunDate($line_id);
  346. $run_id = RunMain::getRunIdByLine($line_id, $run_date, $start_time);
  347. if (!$run_id) {
  348. $result['code'] = '1';
  349. $result['info'] = '该线路无有效班次';
  350. return $result;
  351. }
  352. #1.2遍历获取每单的:乘客,票种,渠道信息
  353. #1.2.1 获取该线路的乘客信息
  354. $customer_arr = BaseTailorStation::getDynamicCustomerInfo($line_id, $main_corp_id);
  355. if (!$customer_arr) {
  356. $result['code'] = '1';
  357. $result['info'] = '该线路无符合条件下单用户';
  358. return $result;
  359. }
  360. //$this->writeLog(json_encode($customer_arr));
  361. #1.2.2 获取票种渠道等信息,并检验数据
  362. $customer_final = array();
  363. foreach ($customer_arr as $k => $v) {
  364. //数据校验
  365. if (!$v['inout_type'] || !$v['address_res_id'] || !$v['product_res_id'] || !$v['product_id'] || !$v['org_id'] || $v['person_num'] < 1) {
  366. $result['code'] = '1';
  367. $result['info'] = '乘客-' . $v['name'] . $v['tel'] . ' 数据不完整';
  368. return $result;
  369. }
  370. if ($v['inout_type'] != 108 && $v['inout_type'] != 110) {
  371. $result['code'] = '1';
  372. $result['info'] = '乘客-' . $v['name'] . $v['tel'] . ' 的站点类型数据库有误';
  373. return $result;
  374. }
  375. //生成票种渠道等信息
  376. $start_res_id = $v['inout_type'] == 108 ? $v['address_res_id'] : $v['product_res_id'];
  377. $end_res_id = $v['inout_type'] == 110 ? $v['address_res_id'] : $v['product_res_id'];
  378. $ticket_arr = OperaTickets::getTicketByRes($line_id, $start_res_id, $end_res_id);
  379. if (!$ticket_arr) {
  380. $result['code'] = '1';
  381. $result['info'] = '乘客-' . $v['name'] . $v['tel'] . ' 的上下车站点无有效票种';
  382. return $result;
  383. }
  384. $v['ticket_id'] = $ticket_arr['ticket_id'];
  385. $v['cost_price'] = $ticket_arr['cost_price'];
  386. $v['prod_price'] = $ticket_arr['prod_price'];
  387. $v['cus_price'] = $ticket_arr['cus_price'];
  388. $customer_final[$k] = $v;
  389. }
  390. //2,批量下单,返回结果
  391. $order_result = array();//批量下单结果数组
  392. foreach ($customer_final as $k => $v) {
  393. #2.1整理下单参数
  394. $prod_str = '{' . '1' . ',' . $run_id . ',' . $v['ticket_id'] . ',' . $v['prod_price'] . ',' . $v['person_num'] . '}';
  395. $order_info_str = '{' . $order_extra_arr['user_id'] . ',' . $order_extra_arr['member_id'] . ',' . $v['org_id'] . ',' . $v['org_no'] . ',' . $order_extra_arr['order_book_status'] . ',' . $order_extra_arr['pay_type'] . ',' . $order_extra_arr['order_pay_status'] . ',' . $order_extra_arr['sale_man'] . '}';
  396. $customer_info_str = '{' . $v['name'] . ',' . $v['tel'] . ',' . $order_extra_arr['customer_id_type'] . ',' . $v['id_card'] . ',' . $v['memo'] . ',' . $v['address'] . '}';
  397. #2.2整合最终下单参数
  398. $url = 'http://' . CS1_DOMAIN . '/api/submit-order';
  399. $send_data = array();
  400. $send_data['action'] = 'submit_bus_order';
  401. $send_data['prod_str'] = $prod_str;//购买票种列表 格式为{去程/返程标志(1:去程 2:返程),去程/返程班次ID,票种ID,票种单价,预定数量,车号}...
  402. $send_data['order_info_str'] = $order_info_str;//'订单信息 {下单用户,会员号,渠道id,渠道订单号,是否自动退票(0否1是),支付方式(授信275),是否支付(0否1是),业务员}'
  403. $send_data['customer_info_str'] = $customer_info_str;//联系人信息,格式为{联系人,联系电话,z证件类型,联系人身份证,备注}
  404. $send_data['order_append_str'] = '{0,0}';//订单附加 ,格式为{门票价格,酒店价格}
  405. $send_data['receiver_value_str'] = '{0,0}';//代收,格式为{代收单价,代收总价}
  406. $send_data['is_send_msg'] = 1;//是否发短信(0否1是) 默认1
  407. $json_res = Msg::httpRequest($url, $send_data);
  408. $res_arr = json_decode($json_res, true);
  409. #2.3 结果插入数组
  410. $tmp_res = array();
  411. $tmp_res['name'] = $v['name'];
  412. $tmp_res['tel'] = $v['tel'];
  413. $tmp_res['code'] = $res_arr['code'];
  414. $tmp_res['customer_param'] = $v; //下单用户信息参数
  415. $tmp_res['order_param'] = $send_data;//下单参数
  416. $tmp_res['return_info'] = $res_arr; //下单返回值参数
  417. $order_result[$v['id'] . '-' . $v['name'] . '-' . $v['tel']] = $tmp_res;
  418. //$this->writeLog(json_encode($tmp_res), 'single_submit_order');//写入log
  419. #2.4 下单如果成功,将订单号反写入
  420. $base_tailor_obj = BaseTailorStation::findOne(['id' => $v['id']]);
  421. if ($res_arr['code'] == '0' && $base_tailor_obj) {
  422. $base_tailor_obj->order_id = $res_arr['data'];
  423. $up_res = $base_tailor_obj->update();
  424. //$this->writeLog($v['id'].'-order_id:'.$base_tailor_obj->order_id, 'base_tailor_obj');//写入log
  425. if ($up_res === false) {
  426. $this->writeLog(json_encode($base_tailor_obj->getErrors()), 'rewrite_order');//写入log
  427. }
  428. }
  429. }
  430. //3,整理返回结果
  431. $count_num = 0;
  432. $total_num = count($customer_final);
  433. $info = '';
  434. $code = '0';
  435. foreach ($order_result as $ok => $ov) {
  436. if ($ov['code'] == '0') {
  437. $count_num++;
  438. }
  439. }
  440. if ($count_num == $total_num) {
  441. $info = '下单成功';
  442. } else if ($count_num == 0) {
  443. $code = '1';
  444. $info = '下单失败';
  445. } else if ($count_num < $total_num) {
  446. $code = '1';
  447. $info = "部分订单下单失败:【全部共$total_num 个订单,下单成功$count_num 个订单】";
  448. } else {
  449. $code = '1';
  450. $info = '未知错误';
  451. }
  452. $result['code'] = $code;
  453. $result['info'] = $info;
  454. $result['list'] = $order_result;
  455. //$this->writeLog(json_encode($order_result), 'submit_dynamic_order');//写入log
  456. return $result;
  457. }
  458. /**
  459. * User: wangxj
  460. *
  461. * 保存日志
  462. *
  463. * @param $action
  464. * @param $string
  465. */
  466. public function writeLog($string, $action = 'record')
  467. {
  468. $string = date('Y-m-d H:i:s') . " $action " . PHP_EOL . $string . PHP_EOL;
  469. if (!file_exists(__DIR__ . '/../log/dynamic')) {
  470. mkdir(__DIR__ . '/../log/dynamic', 0777, true);
  471. }
  472. file_put_contents(__DIR__ . '/../log/dynamic/' . date('Y-m-d') . '.log', $string, FILE_APPEND);
  473. }
  474. }