You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

625 lines
31 KiB

  1. <?php
  2. require_once './php_include/Config2.php';
  3. require_once './php_include/class.db.inc';
  4. require_once './php_include/disney.inc';
  5. //DB
  6. $objDbh = new Db;
  7. $objDbh->setAccount(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB);
  8. $objDisney = new DbDisney($objDbh);
  9. echo '$cs1_array = $objDisney->getCS1Info(43)';
  10. $cs1_array = $objDisney->getCS1Info(48);
  11. print_r($cs1_array);exit();
  12. $cs2_array = $objDisney->getCS2Array();
  13. $go_prod = array();
  14. $back_prod = array();
  15. foreach( $cs1_array as $cs1_info ) {
  16. $go_prod[$cs1_info["org_id"]] = $cs1_info;
  17. }
  18. foreach( $cs2_array as $cs2_info ) {
  19. $back_prod[$cs2_info["org_id"]] = $cs2_info;
  20. }
  21. $limit = " ORDER BY create_time ASC ";
  22. $extra_sql = false;
  23. $order_array = $objDisney->getActiceOrderCommonArray( $extra_sql, $limit );
  24. $oneway_bus = array( 15,16,18 );
  25. $bothway_bus = array(1,17,19);
  26. $dbothway_bus = array(2);
  27. $disney_prod = array(3,4,5,6,7,8);
  28. $lion_prod = array(9,10,11,12,13,14);
  29. foreach( $order_array as $order_info ) {
  30. $order_goods_array = $objDisney->getOrderGoodsArray( $order_info["id"] );
  31. if( false == $order_goods_array ) {
  32. continue;
  33. }
  34. $prod_id =$order_info["prod_id"];
  35. foreach( $order_goods_array as $order_goods_info ) {
  36. $good_id = $order_goods_info["good_id"];
  37. $good_type = 0;
  38. if (in_array($good_id, $disney_prod)) {
  39. $good_type = 1;
  40. } else if (in_array($good_id, $lion_prod)) {
  41. $good_type = 2;
  42. } else if (in_array($good_id, $bothway_bus)) {
  43. $good_type = 3;
  44. } else if (in_array($good_id, $dbothway_bus)) {
  45. $good_type = 4;
  46. } else {
  47. $good_type = 5;
  48. }
  49. }
  50. //insert into disney2cs
  51. $str .= $order_info["order_serial_no"]."\t,".$order_info["prod_name"].$return_flag;
  52. $order_date = $order_info["start_day"];
  53. if( mb_strlen($order_info["start_time"]) > 0 ) {
  54. $order_date .= " ".$order_info["start_time"];
  55. }
  56. if( $order_info["prod_id"] == 1 || $order_info["prod_id"] == 2 || $order_info["prod_id"] == 18 || $order_info["prod_id"] == 16 ) {
  57. $order_date .= "-".$order_info["end_day"]." ".$order_info["end_time"];
  58. if( mb_strlen($order_info["start_time2"]) > 0 ) {
  59. $order_date .= $return_flag.$order_info["start_day2"]." ".$order_info["start_time2"]."-".$order_info["end_day2"]." ".$order_info["end_time2"];
  60. }
  61. }
  62. $str .= $order_date.",";
  63. $str .= $order_info["order_price"].",";
  64. $str .= $order_info["create_time"].",";
  65. if( $order_info['is_payed'] == 1 ) {
  66. $str .= $_ary_pay_type[$order_info['pay_type']].$return_flag.'支付号:'.$order_info["pay_no"] . ',';
  67. } else if( $order_info['order_user_id'] > 0 ){
  68. $str .= '酒店代收现金,';
  69. } else {
  70. $str .= '未支付,';
  71. }
  72. $str .= $order_info["cus_name"].$return_flag.$order_info["cus_mobile"].$return_flag.$order_info["cus_iden"];
  73. $order_comment = str_replace(",",",",$order_info["comment"]);
  74. $str .= ",\"".$order_comment."\"";
  75. $str .= "\n";
  76. }
  77. exit();
  78. /////////////////////////////////////////////////////////////////////////////////
  79. /**
  80. * @param type $user_id 下单用户id
  81. * @param type $playdate 游玩日期
  82. * @param type $create_time 订单创建时间
  83. * @param type $customer_name 顾客姓名
  84. * @param type $customer_phone 顾客电话
  85. * @param type $customer_id_type id类型 150身份证 153 护照
  86. * @param type $customer_id 顾客id号
  87. * @param type $ticket 订票类型 $ticket=array(
  88. 'D'=>0,//成人票
  89. 'C'=>0,//儿童票
  90. 'O'=>0,//老人票
  91. 'D2'=>0,//成人两日票
  92. 'C2'=>0,//儿童两日票
  93. 'O2'=>0,//老人两日票
  94. );
  95. * @param type $return_no 外部订单号
  96. * @param $order_from_org_id 订单对应组织id
  97. */
  98. //addtheater('998', '111', '2122','111', '1111', '22222', '222', '2222', array( 'AA'=>1,'AB'=>1, 'BB'=>0, 'BA'=>0, 'CA'=>0,'CB'=>0), 1111,'0');
  99. //adddisney('998', '111', '2122', '1111', '22222', '222', '2222', array('D'=>1,'C'=>0,'O'=>0,'D2'=>1,'C2'=>0,'O2'=>0), 1111,'0');
  100. function adddisney($user_id,$playdate,$create_time,$customer_name,$customer_phone,$customer_id_type,$customer_id,$ticket,$return_no,$order_from_org_id){
  101. $date =isset($playdate)?$playdate:'0';
  102. $cust_name = isset($customer_name)?$customer_name:'匿名';
  103. $cust_phone = isset($customer_phone)?$customer_phone:'0';
  104. $id_type = isset($customer_id_type)? $customer_id_type:'150'; // 150身份证 153 护照
  105. $customer_id = isset($customer_id)?$customer_id:'0';
  106. $return_no = isset($return_no)? $return_no:'0';
  107. $order_status =146;
  108. $pay_type_id_1 = 275;
  109. $pdo = conn_cs();
  110. $sql = "select a.prod_id,a.prod_name,b.prod_price,b.prod_type_id "
  111. . "from opera_product a inner join opera_product_price b on a.prod_id = b.prod_id "
  112. . "where a.parent_id = 387267";
  113. $result=$pdo->query($sql);
  114. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  115. $info = array();
  116. foreach ($rowset as $v) {
  117. $info[$v['prod_id']] = $v;
  118. }
  119. $sql_p = "select prod_id,prod_name "
  120. . " from opera_product "
  121. . " where prod_id = 387267";
  122. $result_p=$pdo->query($sql_p);
  123. $rowset_p = $result_p -> fetchAll(PDO::FETCH_ASSOC);
  124. $info_p = $rowset_p[0];
  125. $num=0;
  126. $order_description = "";
  127. $price=0;
  128. foreach ($ticket as $k=>$v) {
  129. $num+=$v;
  130. if($v){
  131. switch ($k){
  132. case 'D':
  133. $price+=$info['387538']['prod_price']*$v;
  134. $order_description.=" 标准一日票,". date('Y-m-d',time()).",".$v."|";
  135. break;
  136. case 'C':
  137. $price+=$info['387540']['prod_price']*$v;
  138. $order_description.="儿童一日票,". date('Y-m-d',time()).",".$v."|";
  139. break;
  140. case 'O':
  141. $price+=$info['387539']['prod_price']*$v;
  142. $order_description.="老人一日票,". date('Y-m-d',time()).",".$v."|";
  143. break;
  144. case 'C2':
  145. $price+=$info['387543']['prod_price']*$v;
  146. $order_description.="儿童两日票,". date('Y-m-d',time()).",".$v."|";
  147. break;
  148. case 'D2':
  149. $price+=$info['387541']['prod_price']*$v;
  150. $order_description.="标准两日票,". date('Y-m-d',time()).",".$v."|";
  151. break;
  152. case 'O2':
  153. $price+=$info['387542']['prod_price']*$v;
  154. $order_description.="老人两日票,". date('Y-m-d',time()).",".$v."|";
  155. break;
  156. }
  157. }
  158. }
  159. $id_p = getUniqeId();
  160. $order_id_p = $id_p;
  161. $pay_main_id = getUniqeId();
  162. $create_time;
  163. $update_time = $create_time;
  164. $order_pay_status = 0;
  165. //查找数据库中关于迪士尼的信息
  166. $sql_in=" insert into order_main
  167. (`id`,
  168. `order_id`,
  169. `create_time`,`update_time`,
  170. `order_pay_status`,`order_description`,
  171. `order_price`,`order_prod_type`,`prod_name`,`order_status`,
  172. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  173. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`prod_id`,`run_date`,`main_create_user_id`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`)
  174. values ('".$id_p."','"
  175. .$order_id_p."',
  176. '".$create_time."','".$update_time."','0','".$order_description."','"
  177. .$price."','258','".$info_p['prod_name']."','".$order_status."','
  178. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."','0','0','".$info_p['prod_id']."','".$date."','".$user_id."','".$pay_main_id."','".$order_from_org_id."','".$return_no."')";
  179. for_insert($sql_in);
  180. //插入支付方式等信息
  181. $sql_pay="insert INTO"
  182. . " `order_pay_main`(id,CREATe_user_id,CREATE_time,update_user_id,pay_total) "
  183. . "VALUES(".$pay_main_id.",".$user_id.",'".date('Y-m-d H-i-s', time())."',".$user_id.",".$price.");"
  184. . "insert INTO `order_pay_detail`
  185. (id,CREATe_user_id,CREATE_time,update_user_id,pay_main_id,pay_type_id_1,pay_money)
  186. VALUES(".$pay_main_id.",".$user_id.",'".date('Y-m-d H-i-s', time())."',".$user_id.",".$pay_main_id.",'".$pay_type_id_1."',".$price.");";
  187. for_insert($sql_pay);
  188. foreach ($ticket as $k => $v) {
  189. if($v){
  190. switch ($k){
  191. case 'D':
  192. for($i=1;$i<=$v;$i++){
  193. $id =$order_id =getUniqeId();
  194. $sql = " insert into order_main
  195. (`id`,
  196. `order_id`,
  197. `create_time`,`update_time`,
  198. `order_pay_status`,
  199. `order_prod_type`,`order_status`,
  200. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  201. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  202. values ('".$id."','"
  203. .$order_id."',
  204. '".$create_time."','".$update_time."',
  205. '0','258','".$order_status."','
  206. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  207. '0','0','".$id_p."','".$info['387538']['prod_id']."','".$info_p['prod_id']."','".$info['387538']['prod_name']."','".$info_p['prod_name']."','".$info['387538']['prod_price']."','".$date."','".$pay_main_id."','".$order_from_org_id."','".$return_no."','".$user_id."')";
  208. for_insert($sql);
  209. }
  210. break;
  211. case 'C':
  212. for($i=1;$i<=$v;$i++){
  213. $id =$order_id =getUniqeId();
  214. $sql = " insert into order_main
  215. (`id`,
  216. `order_id`,
  217. `create_time`,`update_time`,
  218. `order_pay_status`,
  219. `order_prod_type`,`order_status`,
  220. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  221. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  222. values ('".$id."','"
  223. .$order_id."',
  224. '".$create_time."','".$update_time."',
  225. '0','258','".$order_status."','
  226. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  227. '0','0','".$id_p."','".$info['387540']['prod_id']."','".$info_p['prod_id']."','".$info['387540']['prod_name']."','".$info_p['prod_name']."','".$info['387540']['prod_price']."','".$date."','".$pay_main_id."','".$order_from_org_id."','".$return_no."','".$user_id."')";
  228. for_insert($sql);
  229. }
  230. break;
  231. case 'O':
  232. for($i=1;$i<=$v;$i++){
  233. $id =$order_id =getUniqeId();
  234. $sql = " insert into order_main
  235. (`id`,
  236. `order_id`,
  237. `create_time`,`update_time`,
  238. `order_pay_status`,
  239. `order_prod_type`,`order_status`,
  240. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  241. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  242. values ('".$id."','"
  243. .$order_id."',
  244. '".$create_time."','".$update_time."',
  245. '0','258','".$order_status."','
  246. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  247. '0','0','".$id_p."','".$info['387539']['prod_id']."','".$info_p['prod_id']."','".$info['387539']['prod_name']."','".$info_p['prod_name']."','".$info['387539']['prod_price']."','".$date."','".$pay_main_id."','".$order_from_org_id."','".$return_no."','".$user_id."')";
  248. for_insert($sql);
  249. }
  250. break;
  251. case 'C2':
  252. for($i=1;$i<=$v;$i++){
  253. $id =$order_id =getUniqeId();
  254. $sql = " insert into order_main
  255. (`id`,
  256. `order_id`,
  257. `create_time`,`update_time`,
  258. `order_pay_status`,
  259. `order_prod_type`,`order_status`,
  260. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  261. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  262. values ('".$id."','"
  263. .$order_id."',
  264. '".$create_time."','".$update_time."',
  265. '0','258','".$order_status."','
  266. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  267. '0','0','".$id_p."','".$info['387543']['prod_id']."','".$info_p['prod_id']."','".$info['387543']['prod_name']."','".$info_p['prod_name']."','".$info['387543']['prod_price']."','".$date."','".$pay_main_id."','".$order_from_org_id."','".$return_no."','".$user_id."')";
  268. for_insert($sql);
  269. }
  270. break;
  271. case 'D2':
  272. for($i=1;$i<=$v;$i++){
  273. $id =$order_id =getUniqeId();
  274. $sql = " insert into order_main
  275. (`id`,
  276. `order_id`,
  277. `create_time`,`update_time`,
  278. `order_pay_status`,
  279. `order_prod_type`,`order_status`,
  280. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  281. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  282. values ('".$id."','"
  283. .$order_id."',
  284. '".$create_time."','".$update_time."',
  285. '0','258','".$order_status."','
  286. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  287. '0','0','".$id_p."','".$info['387541']['prod_id']."','".$info_p['prod_id']."','".$info['387541']['prod_name']."','".$info_p['prod_name']."','".$info['387541']['prod_price']."','".$date."','".$pay_main_id."','".$order_from_org_id."','".$return_no."','".$user_id."')";
  288. for_insert($sql);
  289. }
  290. break;
  291. case 'O2':
  292. for($i=1;$i<=$v;$i++){
  293. $id =$order_id =getUniqeId();
  294. $sql = " insert into order_main
  295. (`id`,
  296. `order_id`,
  297. `create_time`,`update_time`,
  298. `order_pay_status`,
  299. `order_prod_type`,`order_status`,
  300. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  301. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  302. values ('".$id."','"
  303. .$order_id."',
  304. '".$create_time."','".$update_time."',
  305. '0','258','".$order_status."','
  306. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  307. '0','0','".$id_p."','".$info['387542']['prod_id']."','".$info_p['prod_id']."','".$info['387542']['prod_name']."','".$info_p['prod_name']."','".$info['387542']['prod_price']."','".$date."','".$pay_main_id."','".$order_from_org_id."','".$return_no."','".$user_id."')";
  308. for_insert($sql);
  309. }
  310. break;
  311. }
  312. }
  313. }
  314. }
  315. /**
  316. *
  317. * @param type $user_id 下单用户id
  318. * @param type $playdate 游玩日期
  319. * @param type $playtime 开场时间
  320. * @param type $create_time 订单创建时间
  321. * @param type $customer_name 顾客姓名
  322. * @param type $customer_phone 顾客电话
  323. * @param type $customer_id_type id类型 150身份证 153 护照
  324. * @param type $customer_id 顾客id号
  325. * @param type $ticket 订票类型 $ticket=array(
  326. 'AA'=>0,
  327. 'AB'=>0,
  328. 'BB'=>0,
  329. 'BA'=>0,
  330. 'CA'=>0,
  331. 'CB'=>0,
  332. );
  333. * @param type $return_no 外部订单号
  334. * @param $order_from_org_id 订单对应组织id
  335. *
  336. */
  337. function addtheater($user_id,$playdate,$playtime,$create_time,$customer_name,$customer_phone,$customer_id_type,$customer_id,$ticket,$return_no,$order_from_org_id){
  338. $date = $playdate;
  339. $time = $playtime;
  340. $cust_name = $customer_name;
  341. $cust_phone =$customer_phone;
  342. $id_type =$customer_id_type; // 150身份证 153 护照
  343. $customer_id = $customer_id;
  344. // $ticket=array(
  345. // 'AA'=>isset($_POST['AA'])?$_POST['AA']:0,
  346. // 'AB'=>isset($_POST['AB'])?$_POST['AB']:0,
  347. // 'BB'=>isset($_POST['BB'])?$_POST['BB']:0,
  348. // 'BA'=>isset($_POST['BA'])?$_POST['BA']:0,
  349. // 'CA'=>isset($_POST['CA'])?$_POST['CA']:0,
  350. // 'CB'=>isset($_POST['CB'])?$_POST['CB']:0,
  351. // );
  352. $tic_buy =$return_no;
  353. $pdo = conn_cs();
  354. $sql = "select a.prod_id,a.prod_name,b.prod_price,b.prod_type_id "
  355. . "from opera_product a inner join opera_product_price b on a.prod_id = b.prod_id "
  356. . "where a.parent_id = 387544";
  357. $result=$pdo->query($sql);
  358. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  359. $info = array();
  360. foreach ($rowset as $v) {
  361. $info[$v['prod_id']] = $v;
  362. }
  363. $sql_p = "select prod_id,prod_name "
  364. . " from opera_product "
  365. . " where prod_id = 387544";
  366. $result_p=$pdo->query($sql_p);
  367. $rowset_p = $result_p -> fetchAll(PDO::FETCH_ASSOC);
  368. $info_p = $rowset_p[0];
  369. $num=0;
  370. $order_description = "";
  371. $price=0;
  372. $return_info='';
  373. //var_dump($info);die;
  374. foreach ($ticket as $k=>$v) {
  375. $num+=$v;
  376. if($v){
  377. switch ($k){
  378. case 'AA':
  379. $price+=$info['387545']['prod_price']*$v;
  380. $return_info.=' AA区 × '.$v;
  381. $order_description.="迪士尼剧场AA区,". date('Y-m-d',time()).",".$v."|";
  382. break;
  383. case 'AB':
  384. $price+=$info['387546']['prod_price']*$v;
  385. $return_info.=' AB区 × '.$v;
  386. $order_description.="迪士尼剧场AB区,". date('Y-m-d',time()).",".$v."|";
  387. break;
  388. case 'BB':
  389. $price+=$info['387547']['prod_price']*$v;
  390. $return_info.=' BB区 × '.$v;
  391. $order_description.="迪士尼剧场BB区,". date('Y-m-d',time()).",".$v."|";
  392. break;
  393. case 'BA':
  394. $price+=$info['387548']['prod_price']*$v;
  395. $return_info.=' BA区 × '.$v;
  396. $order_description.="迪士尼剧场BA区,". date('Y-m-d',time()).",".$v."|";
  397. break;
  398. case 'CA':
  399. $price+=$info['387549']['prod_price']*$v;
  400. $return_info.=' CA区 × '.$v;
  401. $order_description.="迪士尼剧场CA区,". date('Y-m-d',time()).",".$v."|";
  402. break;
  403. case 'CB':
  404. $price+=$info['387550']['prod_price']*$v;
  405. $return_info.=' CB区 × '.$v;
  406. $order_description.="迪士尼剧场CB区,". date('Y-m-d',time()).",".$v."|";
  407. break;
  408. }
  409. }
  410. }
  411. $pay_status =146;
  412. $pay_type_id_1 = 275;
  413. $id_p = $order_id_p = getUniqeId();
  414. $pay_main_id = getUniqeId();
  415. $update_time =$create_time;
  416. $order_pay_status = 0;
  417. //查找数据库中关于迪士尼的信息
  418. $sql_in=" insert into order_main
  419. (`id`,
  420. `order_id`,
  421. `create_time`,`update_time`,
  422. `order_pay_status`,`order_description`,
  423. `order_price`,`order_prod_type`,`prod_name`,`order_status`,
  424. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  425. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`prod_id`,`run_date`,`run_time`,`main_create_user_id`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`)
  426. values ('".$id_p."','"
  427. .$order_id_p."',
  428. '".$create_time."','".$update_time."','0','".$order_description."','"
  429. .$price."','259','".$info_p['prod_name']."','".$pay_status."','
  430. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."','1','0','".$info_p['prod_id']."','".$date."','".$time."','".$user_id."','".$pay_main_id."','".$order_from_org_id."','".$tic_buy."')";
  431. for_insert($sql_in);
  432. $sql_pay="insert INTO"
  433. . " `order_pay_main`(id,CREATe_user_id,CREATE_time,update_user_id,pay_total) "
  434. . "VALUES(".$pay_main_id.",".$user_id.",'".date('Y-m-d H-i-s', time())."',".$user_id.",".$price.");"
  435. . "insert INTO `order_pay_detail`
  436. (id,CREATe_user_id,CREATE_time,update_user_id,pay_main_id,pay_type_id_1,pay_money)
  437. VALUES(".$pay_main_id.",".$user_id.",'".date('Y-m-d H-i-s', time())."',".$user_id.",".$pay_main_id.",".$pay_type_id_1.",".$price.");";
  438. for_insert($sql_pay);
  439. foreach ($ticket as $k => $v) {
  440. if($v){
  441. switch ($k){
  442. case 'AA':
  443. for($i=1;$i<=$v;$i++){
  444. $id =$order_id =getUniqeId();
  445. $sql = " insert into order_main
  446. (`id`,
  447. `order_id`,
  448. `create_time`,`update_time`,
  449. `order_pay_status`,
  450. `order_prod_type`,`order_status`,
  451. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  452. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  453. values ('".$id."','"
  454. .$order_id."',
  455. '".$create_time."','".$update_time."',
  456. '0','259','".$pay_status."','
  457. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  458. '0','0','".$id_p."','".$info['387545']['prod_id']."','".$info_p['prod_id']."','".$info['387545']['prod_name']."','".$info_p['prod_name']."','".$info['387545']['prod_price']."','".$date."','".$time."','".$pay_main_id."','".$order_from_org_id."','".$tic_buy."','".$user_id."')";
  459. for_insert($sql);
  460. }
  461. break;
  462. case 'AB':
  463. for($i=1;$i<=$v;$i++){
  464. $id =$order_id =getUniqeId();
  465. $sql = " insert into order_main
  466. (`id`,
  467. `order_id`,
  468. `create_time`,`update_time`,
  469. `order_pay_status`,
  470. `order_prod_type`,`order_status`,
  471. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  472. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  473. values ('".$id."','"
  474. .$order_id."',
  475. '".$create_time."','".$update_time."',
  476. '0','259','".$pay_status."','
  477. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  478. '0','0','".$id_p."','".$info['387546']['prod_id']."','".$info_p['prod_id']."','".$info['387546']['prod_name']."','".$info_p['prod_name']."','".$info['387546']['prod_price']."','".$date."','".$time."','".$pay_main_id."','".$order_from_org_id."','".$tic_buy."','".$user_id."')";
  479. for_insert($sql);
  480. }
  481. break;
  482. case 'BB':
  483. for($i=1;$i<=$v;$i++){
  484. $id =$order_id =getUniqeId();
  485. $sql = " insert into order_main
  486. (`id`,
  487. `order_id`,
  488. `create_time`,`update_time`,
  489. `order_pay_status`,
  490. `order_prod_type`,`order_status`,
  491. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  492. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  493. values ('".$id."','"
  494. .$order_id."',
  495. '".$create_time."','".$update_time."',
  496. '0','259','".$pay_status."','
  497. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  498. '0','0','".$id_p."','".$info['387547']['prod_id']."','".$info_p['prod_id']."','".$info['387547']['prod_name']."','".$info_p['prod_name']."','".$info['387547']['prod_price']."','".$date."','".$time."','".$pay_main_id."','".$order_from_org_id."','".$tic_buy."','".$user_id."')";
  499. for_insert($sql);
  500. }
  501. break;
  502. case 'BA':
  503. for($i=1;$i<=$v;$i++){
  504. $id =$order_id =getUniqeId();
  505. $sql = " insert into order_main
  506. (`id`,
  507. `order_id`,
  508. `create_time`,`update_time`,
  509. `order_pay_status`,
  510. `order_prod_type`,`order_status`,
  511. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  512. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  513. values ('".$id."','"
  514. .$order_id."',
  515. '".$create_time."','".$update_time."',
  516. '0','259','".$pay_status."','
  517. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  518. '0','0','".$id_p."','".$info['387548']['prod_id']."','".$info_p['prod_id']."','".$info['387548']['prod_name']."','".$info_p['prod_name']."','".$info['387548']['prod_price']."','".$date."','".$time."','".$pay_main_id."','".$order_from_org_id."','".$tic_buy."','".$user_id."')";
  519. for_insert($sql);
  520. }
  521. break;
  522. case 'CA':
  523. for($i=1;$i<=$v;$i++){
  524. $id =$order_id =getUniqeId();
  525. $sql = " insert into order_main
  526. (`id`,
  527. `order_id`,
  528. `create_time`,`update_time`,
  529. `order_pay_status`,
  530. `order_prod_type`,`order_status`,
  531. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  532. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  533. values ('".$id."','"
  534. .$order_id."',
  535. '".$create_time."','".$update_time."',
  536. '0','259','".$pay_status."','
  537. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  538. '0','0','".$id_p."','".$info['387549']['prod_id']."','".$info_p['prod_id']."','".$info['387549']['prod_name']."','".$info_p['prod_name']."','".$info['387549']['prod_price']."','".$date."','".$time."','".$pay_main_id."','".$order_from_org_id."','".$tic_buy."','".$user_id."')";
  539. for_insert($sql);
  540. }
  541. break;
  542. case 'CB':
  543. for($i=1;$i<=$v;$i++){
  544. $id =$order_id =getUniqeId();
  545. $sql = " insert into order_main
  546. (`id`,
  547. `order_id`,
  548. `create_time`,`update_time`,
  549. `order_pay_status`,
  550. `order_prod_type`,`order_status`,
  551. `customer_name`,`customer_mobile`,`customer_id_type`,`customer_id_no`,
  552. `order_book_status`,`PROD_START_STATION_TIME_MINUTES`,`parent_order_id`,`prod_id`,`parent_prod_id`,`prod_name`,`parent_prod_name`,`order_price`,`run_date`,`run_time`,`order_pay_main_id`,`outside_sale_org_id`,`outside_order_no`,`main_create_user_id`)
  553. values ('".$id."','"
  554. .$order_id."',
  555. '".$create_time."','".$update_time."',
  556. '0','259','".$pay_status."','
  557. ".$cust_name."','".$cust_phone."','".$id_type."','".$customer_id."',
  558. '0','0','".$id_p."','".$info['387550']['prod_id']."','".$info_p['prod_id']."','".$info['387550']['prod_name']."','".$info_p['prod_name']."','".$info['387550']['prod_price']."','".$date."','".$time."','".$pay_main_id."','".$order_from_org_id."','".$tic_buy."','".$user_id."')";
  559. for_insert($sql);
  560. }
  561. break;
  562. }
  563. }}
  564. }
  565. function for_insert($sql){
  566. $pdo = conn_cs();
  567. $re = $pdo->exec($sql);
  568. if($re==0){
  569. echo $sql;
  570. exit ;
  571. }
  572. }
  573. function conn_cs() {
  574. $port=8090;
  575. $host = "180.168.4.58";
  576. $dbname = "ctsdata_test";
  577. $dbuser = "root";
  578. $dbpassword = "123456";
  579. try {
  580. $pdo=new PDO("mysql:host=".$host.";port=".$port.";dbname=".$dbname, $dbuser, $dbpassword,array(PDO::MYSQL_ATTR_INIT_COMMAND => "set names utf8"));
  581. return $pdo;
  582. }catch (PDOException $e){
  583. writeLog('new PDO failed:'.$e->getMessage());
  584. }
  585. }