OrderPay.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\BaseController;
  4. use app\admin\model\ReportCode;use think\App;
  5. use think\facade\Db;use think\queue\command\Retry;
  6. class OrderPay extends BaseController{
  7. public function __construct(App $app) {parent::__construct($app);}
  8. //新建资金认领数据
  9. public function create(){
  10. $tradNo = isset($this->post['tradNo'])&&$this->post['tradNo']!=""?trim($this->post['tradNo']):"";
  11. if($tradNo==""){
  12. return error_show(1004,"参数 tradNo 不能为空");
  13. }
  14. $orderArr = isset($this->post['orderArr'])&&!empty($this->post['orderArr'])?$this->post['orderArr']:[];
  15. if(empty($orderArr)){
  16. return error_show(1004,"参数 orderArr 不能为空");
  17. }
  18. Db::startTrans();
  19. try{
  20. $logNo=makeNo("TRC");
  21. $trade =Db::name("trade")->where(["tradNo"=>$tradNo,"is_del"=>0])->lock(true)->findOrEmpty();
  22. if(empty($trade)){
  23. Db::rollback();
  24. return error_show(1004,"未找到资金信息");
  25. }
  26. $total_fee =array_sum(array_column($orderArr,"trad_fee"));
  27. if ($trade['balance']<$total_fee){
  28. Db::rollback();
  29. return error_show(1004,"资金余额不足核销");
  30. }
  31. $assoc=[];
  32. foreach ($orderArr as $value){
  33. if(!isset($value['sequenceNo'])||$value['sequenceNo']==""){
  34. Db::rollback();
  35. return error_show(1004,"销售单编号不能为空");
  36. }
  37. if(!isset($value['trad_fee'])||$value['trad_fee']==""){
  38. Db::rollback();
  39. return error_show(1004,"销售单核销金额不能为空");
  40. }
  41. $qrd =Db::name("qrd_info")->where("sequenceNo","=",$value['sequenceNo'])->field("id,customerNo,status,pay_fee,wpay_fee,pay_status,totalPrice")->findOrEmpty();
  42. if(empty($qrd)){
  43. Db::rollback();
  44. return error_show(1004,"销售单信息未找到");
  45. }
  46. if($qrd['wpay_fee']<$value['trad_fee']){
  47. Db::rollback();
  48. return error_show(1004,"销售单未付款金额不足核销金额");
  49. }
  50. $updt=[
  51. "pay_fee"=>$qrd['pay_fee']+$value['trad_fee'],
  52. "wpay_fee"=>$qrd['wpay_fee']-$value['trad_fee'],
  53. "pay_status"=>2,
  54. "status"=>1,
  55. "updatetime"=>date("Y-m-d H:i:s")
  56. ];
  57. $qrdup = Db::name("qrd_info")->where($qrd)->update($updt);
  58. if($qrdup==false){
  59. Db::rollback();
  60. return error_show(1004,"销售单核销金额失败");
  61. }
  62. $temp=[
  63. "assocNo"=>makeNo("AS"),
  64. "apply_id"=>$this->uid,
  65. "apply_name"=>$this->uname,
  66. "type"=>2,
  67. "orderCode"=>$value['sequenceNo'],
  68. "customerNo"=>$qrd['customerNo'],
  69. "viceCode"=>$logNo,
  70. "order_total"=>$qrd['totalPrice'],
  71. "vice_total"=>$total_fee,
  72. "cancel_fee"=>$value['trad_fee'],
  73. "status"=>1,
  74. "addtime"=>date("Y-m-d H:i:s"),
  75. "updatetime"=>date("Y-m-d H:i:s")
  76. ];
  77. $assoc[]=$temp;
  78. $report=ReportCode::where(["qrdNo"=>$value['sequenceNo']])->find();
  79. if($report)$report->setField("logNo",$logNo);
  80. if($report)$report->setField("tradNo",$tradNo);
  81. }
  82. $asscin= Db::name("assoc")->insertAll($assoc);
  83. if($asscin!=count($assoc)){
  84. Db::rollback();
  85. return error_show(1004,"销售单核销金额关联失败");
  86. }
  87. $update=[
  88. "balance"=>$trade['balance']-$total_fee,
  89. "used_fee"=>$trade['used_fee']+$total_fee,
  90. "status"=>($trade['balance']-$total_fee)==0 ? 3:2,
  91. "updatetime"=>date("Y-m-d H:i:s"),
  92. ];
  93. $tradup=Db::name("trade")->where($trade)->update($update);
  94. if($tradup){
  95. $create = [
  96. "logNo"=>$logNo,
  97. "tradNo"=>$tradNo,
  98. "companyNo"=>$trade['companyNo'],
  99. "apply_id"=>$this->uid,
  100. "apply_name"=>$this->uname,
  101. "trade_time"=>$trade['trade_time'],
  102. "total_fee"=>$total_fee,
  103. "status"=>1,
  104. "addtime"=>date("Y-m-d H:i:s"),
  105. "updatetime"=>date("Y-m-d H:i:s")
  106. ];
  107. $tradchild =Db::name("trade_pool")->insert($create);
  108. if($tradchild){
  109. Db::commit();
  110. return app_show(0,"资金认领成功",["logNo"=>$logNo]);
  111. }
  112. }
  113. Db::rollback();
  114. return error_show(1004,"资金认领失败");
  115. }catch (\Exception $e){
  116. Db::rollback();
  117. return error_show(1004,$e->getMessage());
  118. }
  119. }
  120. // 1待审批2审批通过3审批驳回4退款5解除认领
  121. public function status(){
  122. $logNo = isset($this->post['logNo'])&&$this->post['logNo']!=""?trim($this->post['logNo']):"";
  123. if($logNo==""){
  124. return error_show(1004,"参数logNo不能为空");
  125. }
  126. $logingo= Db::name("trade_pool")->where(["logNo"=>$logNo,"is_del"=>0])->find();
  127. if($logingo==false){
  128. return error_show(1004,"资金认领信息未找到");
  129. }
  130. $status=isset($this->post['status'])&&$this->post['status']!=""?intval($this->post['status']):"";
  131. if($status==""){
  132. return error_show(1004,"参数 status 不能为空");
  133. }
  134. if($status==4 &&$logingo['status']!=1 ){
  135. return error_show(1004,"认领资金状态有误");
  136. }
  137. $remark=isset($this->post['remark'])&&$this->post['remark']!=""?trim($this->post['remark']):"";
  138. $trade =Db::name("trade")->where(["tradNo"=>$logingo['tradNo'],"is_del"=>0])->findOrEmpty();
  139. if(empty($trade)){
  140. return error_show(1005,"资金信息未找到");
  141. }
  142. Db::startTrans();
  143. try {
  144. $up=["status"=>$status,"updatetime"=>date("Y-m-d H:i:s"),"remark"=>$remark];
  145. $logup = Db::name("trade_pool")->where($logingo)->update($up);
  146. if($logup){
  147. if($status==2){
  148. $qrdArr=Db::name("assoc")->where(["viceCode"=>$logNo,"status"=>1,"is_del"=>0])->select()->toArray();
  149. if(!empty($qrdArr)){
  150. foreach ($qrdArr as $value){
  151. $qrd =Db::name("qrd_info")->where(["sequenceNo"=>$value['orderCode']])->field("id,status,pay_fee,apay_fee,wpay_fee,pay_status,totalPrice")->findOrEmpty();
  152. if(empty($qrd)){
  153. Db::rollback();
  154. return error_show(1005,"未找到销售单数据");
  155. }
  156. if($qrd['pay_fee']<$value['cancel_fee']){
  157. Db::rollback();
  158. return error_show(1005,"销售单待付金额不足");
  159. }
  160. $update =[
  161. "apay_fee"=>$qrd['apay_fee']+$value['cancel_fee'],
  162. "pay_fee"=>$qrd['pay_fee']-$value['cancel_fee'],
  163. "paytime"=>date("Y-m-d H:i:s"),
  164. "pay_status"=>$qrd['wpay_fee']==0 && ($qrd['pay_fee']-$value['cancel_fee'])==0 ? 3:2,
  165. "updatetime"=>date("Y-m-d H:i:s")
  166. ];
  167. $qrdup =Db::name("qrd_info")->where($qrd)->update($update);
  168. if($qrdup==false){
  169. Db::rollback();
  170. return error_show(1005,"销售单更新失败");
  171. }
  172. $asscup =[
  173. "status"=>2,
  174. "assoc_time"=>date("Y-m-d H:i:s"),
  175. "updatetime"=>date("Y-m-d H:i:s")
  176. ];
  177. $assc=Db::name("assoc")->where($value)->update($asscup);
  178. if($assc==false){
  179. Db::rollback();
  180. return error_show(1005,"销售单更新失败");
  181. }
  182. }
  183. }
  184. }
  185. if($status==3 || $status==4){
  186. $qrdArr=Db::name("assoc")->where(["viceCode"=>$logNo,"status"=>1,"is_del"=>0])->select()->toArray();
  187. if(!empty($qrdArr)){
  188. foreach ($qrdArr as $value){
  189. $qrd =Db::name("qrd_info")->where(["sequenceNo"=>$value['orderCode']])->field("id,status,pay_fee,apay_fee,wpay_fee,pay_status,totalPrice")->findOrEmpty();
  190. if(empty($qrd)){
  191. Db::rollback();
  192. return error_show(1005,"未找到销售单数据");
  193. }
  194. if($qrd['pay_fee']<$value['cancel_fee']){
  195. Db::rollback();
  196. return error_show(1005,"销售单待付金额不足");
  197. }
  198. $update =[
  199. "wpay_fee"=>$qrd['wpay_fee']+$value['cancel_fee'],
  200. "pay_fee"=>$qrd['pay_fee']-$value['cancel_fee'],
  201. "pay_status"=>$qrd['apay_fee']==0 && ($qrd['pay_fee']-$value['cancel_fee'])==0 ? 1:2,
  202. "status"=>$qrd['apay_fee']==0 && ($qrd['pay_fee']-$value['cancel_fee'])==0 ?0:1,
  203. "updatetime"=>date("Y-m-d H:i:s")
  204. ];
  205. $qrdup =Db::name("qrd_info")->where($qrd)->update($update);
  206. if($qrdup==false){
  207. Db::rollback();
  208. return error_show(1005,"销售单更新失败");
  209. }
  210. $asscup =[
  211. "status"=>3,
  212. "updatetime"=>date("Y-m-d H:i:s")
  213. ];
  214. $assc=Db::name("assoc")->where($value)->update($asscup);
  215. if($assc==false){
  216. Db::rollback();
  217. return error_show(1005,"销售单更新失败");
  218. }
  219. $report=ReportCode::where(["qrdNo"=>$value['orderCode']])->find();
  220. if($report)$report->rmField("logNo",$logNo);
  221. }
  222. }
  223. if($trade['used_fee']<$logingo['total_fee']){
  224. Db::rollback();
  225. return error_show(1005,"资金信息已认领金额不足");
  226. }
  227. $tradup =[
  228. "used_fee"=>$trade['used_fee']-$logingo['total_fee'],
  229. "balance"=>$trade['balance']+$logingo['total_fee'],
  230. "status"=>($trade['used_fee']-$logingo['total_fee'])==0 ? 1 :2,
  231. "updatetime"=>date("Y-m-d H:i:s")
  232. ];
  233. $updaT=Db::name("trade")->where($trade)->update($tradup);
  234. if($updaT==false){
  235. Db::rollback();
  236. return error_show(1005,"资金信息更新失败");
  237. }
  238. }
  239. Db::commit();
  240. return app_show(0,"审核成功");
  241. }
  242. Db::rollback();
  243. return error_show(1004,"审核失败");
  244. }catch (\Exception $e){
  245. Db::rollback();
  246. return error_show(1004,$e->getMessage());
  247. }
  248. }
  249. //资金信息列表
  250. public function list(){
  251. $condition=[];
  252. $page=isset($this->post['page'])&&$this->post['page']!="" ? intval($this->post['page']) :1;
  253. $size=isset($this->post['size'])&&$this->post['size']!="" ? intval($this->post['size']) :15;
  254. $name =isset($this->post['name'])&&$this->post['name']!=""? trim($this->post['name']):"";
  255. $bank =isset($this->post['bank'])&&$this->post['bank']!=""? trim($this->post['bank']):"";
  256. $start =isset($this->post['start'])&&$this->post['start']!=""? trim($this->post['start']):"";
  257. $end =isset($this->post['end'])&&$this->post['end']!=""? trim($this->post['end']):"";
  258. $status =isset($this->post['status'])&&$this->post['status']!==""? intval($this->post['status']):"";
  259. $tradNo =isset($this->post['tradNo'])&&$this->post['tradNo']!=""? trim($this->post['tradNo']):"";
  260. $companyNo =isset($this->post['companyNo'])&&$this->post['companyNo']!=""? trim($this->post['companyNo']):"";
  261. $used_lower =isset($this->post['userd_lower'])&&$this->post['userd_lower']!==""? floor($this->post['userd_lower']) :"0";
  262. $used_upper =isset($this->post['used_upper'])&&$this->post['used_upper']!==""? floor($this->post['used_upper']):"";
  263. if($used_lower!=="")$condition[]=["used_fee",">=",$used_lower];
  264. if($used_upper!=="")$condition[]=["used_fee","<=",$used_upper];
  265. if($companyNo!==""){
  266. $condition[]=["companyNo","=",$companyNo];
  267. }
  268. $relaComNo= isset($post['relaComNo'])&&$post['relaComNo']!="" ? trim($post['relaComNo']) :"";
  269. if($relaComNo!=""){
  270. $condition[]=["companyNo","=",$relaComNo];
  271. }
  272. if($tradNo!==""){
  273. $condition[]=["tradNo","like","%$tradNo%"];
  274. }
  275. if($bank!=""){
  276. $condition[]=["trade_bank","like","%$bank%"];
  277. }
  278. if($name!=""){
  279. $condition[]=["trade_out","like","%$name%"];
  280. }
  281. if($start!=""){
  282. $condition[]=["trade_time",">=",$start." 00:00:00"];
  283. }
  284. if($end!=""){
  285. $condition[]=["trade_time","<=",$end." 23:59:59"];
  286. }
  287. if($status!==""){
  288. $condition[]=["status","=",$status];
  289. }
  290. $count=Db::name("trade")->where($condition)->count();
  291. $total=ceil($count/$size);
  292. $page=$page>$total? intval($total):$page;
  293. $list =Db::name("trade")->where($condition)->page($page,$size)->order("addtime desc")->select()->toArray();
  294. foreach ($list as &$value){
  295. $data = Db::name("trade_pool")->alias("a")
  296. ->leftJoin("assoc b","a.logNo=b.viceCode")
  297. ->leftJoin("qrd_info c","b.orderCode=c.sequenceNo")
  298. ->where(["a.tradNo"=>$value['tradNo'],"a.is_del"=>0])
  299. ->order("a.addtime desc")
  300. ->field("a.*,b.orderCode,c.qrdSource,goodNo,goodName,qrdType,c.ownerName,c.ownerid,c.department,c.poCode")
  301. ->select()->toArray();
  302. $value['child']=$data;
  303. }
  304. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  305. }
  306. // 认领资金列表明细
  307. public function tradeList(){
  308. $page=isset($this->post['page'])&&$this->post['page']!="" ? intval($this->post['page']) :1;
  309. $size=isset($this->post['size'])&&$this->post['size']!="" ? intval($this->post['size']) :15;
  310. $condition =[["a.is_del","=",0],["b.is_del","=",0]];
  311. $name =isset($this->post['name'])&&$this->post['name']!=""? trim($this->post['name']):"";
  312. $bank =isset($this->post['bank'])&&$this->post['bank']!=""? trim($this->post['bank']):"";
  313. $start =isset($this->post['start'])&&$this->post['start']!=""? trim($this->post['start']):"";
  314. $end =isset($this->post['end'])&&$this->post['end']!=""? trim($this->post['end']):"";
  315. $status =isset($this->post['status'])&&$this->post['status']!==""? intval($this->post['status']):"";
  316. $apply_id =isset($this->post['apply_id'])&&$this->post['apply_id']!=""? intval($this->post['apply_id']):"";
  317. $apply_name =isset($this->post['apply_name'])&&$this->post['apply_name']!=""? trim($this->post['apply_name']):"";
  318. $tradNo =isset($this->post['tradNo'])&&$this->post['tradNo']!=""? trim($this->post['tradNo']):"";
  319. $orderCode =isset($this->post['orderCode'])&&$this->post['orderCode']!=''?trim($this->post['orderCode']):"";
  320. $companyNo =isset($this->post['companyNo'])&&$this->post['companyNo']!=""? trim($this->post['companyNo']):"";
  321. if($companyNo!==""){
  322. $condition[]=["a.companyNo","=",$companyNo];
  323. }
  324. $relaComNo= isset($post['relaComNo'])&&$post['relaComNo']!="" ? trim($post['relaComNo']) :"";
  325. if($relaComNo!=""){
  326. $condition[]=["companyNo","=",$relaComNo];
  327. }
  328. if($tradNo!==""){
  329. $condition[]=["a.tradNo","like","%$tradNo%"];
  330. }
  331. if($orderCode!==""){
  332. $condition[]=["d.orderCode","like","%$orderCode%"];
  333. }
  334. $logNo =isset($this->post['logNo'])&&$this->post['logNo']!=""? trim($this->post['logNo']):"";
  335. if($logNo!==""){
  336. $condition[]=["a.logNo","like","%$logNo%"];
  337. }
  338. if($bank!=""){
  339. $condition[]=["b.trade_bank","like","%$bank%"];
  340. }
  341. if($name!=""){
  342. $condition[]=["b.trade_out","like","%$name%"];
  343. }
  344. if($start!=""){
  345. $condition[]=["a.add_time",">=",$start." 00:00:00"];
  346. }
  347. if($end!=""){
  348. $condition[]=["a.add_time","<=",$end." 23:59:59"];
  349. }
  350. if($status!==""){
  351. $condition[]=["a.status","=",$status];
  352. }
  353. if($apply_id!==""){
  354. $condition[]=["a.apply_id","=",$apply_id];
  355. }
  356. if($apply_name!==""){
  357. $condition[]=["a.apply_name","like","%$apply_name%"];
  358. }
  359. $count=Db::name("trade_pool")->alias("a")
  360. ->leftJoin("trade b","a.tradNo=b.tradNo")
  361. ->leftJoin("assoc d","a.logNo=d.viceCode")
  362. ->leftJoin("qrd_info c","d.orderCode=c.sequenceNo")
  363. ->where($condition)->count();
  364. $total=ceil($count/$size);
  365. $page=$page>$total? intval($total):$page;
  366. $list =Db::name("trade_pool")->alias("a")
  367. ->leftJoin("trade b","a.tradNo=b.tradNo")
  368. ->leftJoin("assoc d","a.logNo=d.viceCode")
  369. ->leftJoin("qrd_info c","d.orderCode=c.sequenceNo")
  370. ->where($condition)
  371. ->page($page,$size)
  372. ->field("a.*,b.trade_bank,b.trade_account,b.trade_out,b.total_fee as btotal_fee,b.used_fee,b.balance,
  373. d.orderCode,c.qrdSource,c.goodNo,c.goodName,c.qrdType,c.ownerName,c.ownerid,c.department,c.poCode,c.platName,c.totalPrice,d.cancel_fee")
  374. ->order("a.addtime desc")->select();
  375. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  376. }
  377. // 获取资金下面的认领信息
  378. public function tradeQuery(){
  379. $tradNo =isset($this->post['tradNo'])&&$this->post['tradNo']!=""? trim($this->post['tradNo']):"";
  380. $status =isset($this->post['status'])&&$this->post['status']!=""? intval($this->post['status']):"";
  381. $apply_id =isset($this->post['apply_id'])&&$this->post['apply_id']!=""? intval($this->post['apply_id']):"";
  382. $apply_name =isset($this->post['apply_name'])&&$this->post['apply_name']!=""? trim($this->post['apply_name']):"";
  383. $companyNo =isset($this->post['companyNo'])&&$this->post['companyNo']!=""? trim($this->post['companyNo']):"";
  384. if($companyNo!==""){
  385. $condition[]=["companyNo","=",$companyNo];
  386. }
  387. $relaComNo= isset($post['relaComNo'])&&$post['relaComNo']!="" ? trim($post['relaComNo']) :"";
  388. if($relaComNo!=""){
  389. $condition[]=["companyNo","=",$relaComNo];
  390. }
  391. $condition=[["is_del","=",0]];
  392. if($apply_id!==""){
  393. $condition[]=["apply_id","=",$apply_id];
  394. }
  395. if($apply_name!==""){
  396. $condition[]=["apply_name","like","%$apply_name%"];
  397. }
  398. if($status!==""){
  399. $condition[]=["status","=",$status];
  400. }
  401. if($tradNo!==""){
  402. $condition[]=["tradNo","like","%$tradNo%"];
  403. }
  404. $list =Db::name("trade_pool")->where($condition)->order("addtime desc")->select();
  405. return app_show(0,"获取成功",$list);
  406. }
  407. //资金详情
  408. public function tradeInfo(){
  409. $tradNo =isset($this->post['tradNo'])&&$this->post['tradNo']!=""? trim($this->post['tradNo']):"";
  410. if($tradNo==""){
  411. return error_show(1004,"参数 tradNo 不能为空");
  412. }
  413. $tradinfo = Db::name("trade")->where(["tradNo"=>$tradNo,"is_del"=>0])->find();
  414. if($tradinfo==false){
  415. return error_show(1004,"资金信息未找到");
  416. }
  417. return app_show(0,"获取成功",$tradinfo);
  418. }
  419. //资金认领详情
  420. public function logInfo(){
  421. $logNo =isset($this->post['logNo'])&&$this->post['logNo']!=""? trim($this->post['logNo']):"";
  422. if($logNo==""){
  423. return error_show(1004,"参数 logNo 不能为空");
  424. }
  425. $tradinfo = Db::name("trade_pool")->where(["logNo"=>$logNo,"is_del"=>0])->find();
  426. if($tradinfo==false){
  427. return error_show(1004,"资金信息未找到");
  428. }
  429. $trade = Db::name("trade")->where(["tradNo"=>$tradinfo['tradNo'],"is_del"=>0])->find();
  430. $tradinfo['trade_out']= $trade['trade_out']??"";
  431. $tradinfo['trade_in']= $trade['trade_in']??"";
  432. $tradinfo['trade_bank']= $trade['trade_bank']??"";
  433. $tradinfo['customerNo']= $trade['customerNo']??"";
  434. $tradinfo['companyNo']= $trade['companyNo']??"";
  435. $tradinfo['total_fee']= $trade['total_fee']??"";
  436. $tradinfo['balance']= $trade['balance']??"";
  437. $tradinfo['used_fee']= $trade['used_fee']??"";
  438. $orderinfo = Db::name("assoc")->alias("a")->leftJoin("qrd_info c","a.orderCode=c.sequenceNo")
  439. ->where(["a.viceCode"=>$logNo,"a.is_del"=>0,"a.status"=>[1,2,3]])
  440. ->order("a.addtime desc")
  441. ->field("c.*,a.cancel_fee")
  442. ->findOrEmpty();
  443. $tradinfo['orderinfo']=$orderinfo;
  444. return app_show(0,"获取成功",$tradinfo);
  445. }
  446. //认领资金退回或退款 type 1 退款 2 解除资金认领
  447. public function ReturnPay(){
  448. $logNo = isset($this->post['logNo'])&&$this->post['logNo']!="" ? trim($this->post['logNo']):"";
  449. if($logNo==''){
  450. return error_show(1004,"参数 logNo 不能为空");
  451. }
  452. $type = isset($this->post['type'])&&$this->post['type']!="" ? intval($this->post['type']):"";
  453. if($type==""){
  454. return error_show(1004,"参数 type 不能为空");
  455. }
  456. $loginfo = Db::name("trade_pool")->where(["logNo"=>$logNo,"is_del"=>0])->find();
  457. if($loginfo==false){
  458. return error_show(1004,"认领资金信息未找到");
  459. }
  460. if($loginfo['status']==2 && $type==1)return error_show(1004,"认领资金信息审核已通过");
  461. if($loginfo['status']!=2 && $type==2)return error_show(1004,"认领资金信息未审核通过");
  462. $tradinfo = Db::name("trade")->where(["tradNo"=>$loginfo['tradNo'],"is_del"=>0])->find();
  463. if($tradinfo==false){
  464. return error_show(1004,"资金信息未找到");
  465. }
  466. $reason = isset($this->post['return_reason'])&&$this->post['return_reason']!="" ? trim($this->post['return_reason']):"";
  467. $remark = isset($this->post['remark'])&&$this->post['remark']!="" ? trim($this->post['remark']):"";
  468. $returnCode =makeNo("RTA");
  469. $data=[
  470. "returnCode"=>$returnCode,
  471. "logNo"=>$logNo,
  472. "companyNo"=>$tradinfo['companyNo'],
  473. "tradNo"=>$loginfo['tradNo'],
  474. "type"=>$type,
  475. "apply_id"=>$this->uid,
  476. "apply_name"=>$this->uname,
  477. "return_reason"=>$reason,
  478. "remark"=>$remark,
  479. "addtime"=>date("Y-m-d H:i:s"),
  480. "updatetime"=>date("Y-m-d H:i:s")
  481. ];
  482. $in = Db::name("trade_return")->insert($data);
  483. if($in){
  484. return app_show(0,"申请新建成功");
  485. }else{
  486. return error_show(1004,"申请新建失败");
  487. }
  488. }
  489. /**退款列表
  490. * //page size tradNo logNo apply_id apply_name type status returnCode
  491. * @return \think\response\Json|void
  492. * @throws \think\db\exception\DataNotFoundException
  493. * @throws \think\db\exception\DbException
  494. * @throws \think\db\exception\ModelNotFoundException
  495. */
  496. public function returnList(){
  497. $page=isset($this->post['page'])&&$this->post['page']!='' ? intval($this->post['page']):1;
  498. $size=isset($this->post['size'])&&$this->post['size']!='' ? intval($this->post['size']):15;
  499. $tradNo =isset($this->post['tradNo'])&&$this->post['tradNo']!=''?trim($this->post['tradNo']):"";
  500. $logNo =isset($this->post['logNo'])&&$this->post['logNo']!=''?trim($this->post['logNo']):"";
  501. $apply_id =isset($this->post['apply_id'])&&$this->post['apply_id']!=''?intval($this->post['apply_id']):"";
  502. $apply_name =isset($this->post['apply_name'])&&$this->post['apply_name']!=''?trim($this->post['apply_name']):"";
  503. $type =isset($this->post['type'])&&$this->post['type']!=''?intval($this->post['type']):"";
  504. $status =isset($this->post['status'])&&$this->post['status']!==''?intval($this->post['status']):"";
  505. $returnCode =isset($this->post['returnCode'])&&$this->post['returnCode']!=''?trim($this->post['returnCode']):"";
  506. $orderCode =isset($this->post['orderCode'])&&$this->post['orderCode']!=''?trim($this->post['orderCode']):"";
  507. $companyNo =isset($this->post['companyNo'])&&$this->post['companyNo']!=""? trim($this->post['companyNo']):"";
  508. if($companyNo!==""){
  509. $condition[]=["a.companyNo","=",$companyNo];
  510. }
  511. $relaComNo= isset($post['relaComNo'])&&$post['relaComNo']!="" ? trim($post['relaComNo']) :"";
  512. if($relaComNo!=""){
  513. $condition[]=["a.companyNo","=",$relaComNo];
  514. }
  515. $condition=[["a.is_del","=",0]];
  516. if($tradNo!=''){
  517. $condition[]=["a.tradNo","like","%$tradNo%"];
  518. }
  519. if($orderCode!=''){
  520. $condition[]=["b.orderCode","like","%$orderCode%"];
  521. }
  522. if($logNo!=''){
  523. $condition[]=["a.logNo","like","%$logNo%"];
  524. }
  525. if($apply_id!=''){
  526. $condition[]=["a.apply_id","=",$apply_id];
  527. }
  528. if($apply_name!=''){
  529. $condition[]=["a.apply_name","like","%$apply_name%"];
  530. }
  531. if($returnCode!=''){
  532. $condition[]=["a.returnCode","like","%$returnCode%"];
  533. }
  534. if($type!=''){
  535. $condition[]=["a.type","=",$type];
  536. }
  537. if($status!==''){
  538. $condition[]=["a.status","=",$status];
  539. }
  540. $count =Db::name("trade_return")->alias("a")
  541. ->leftJoin("assoc b","a.logNo=b.viceCode")
  542. ->leftJoin("qrd_info c","c.sequenceNo=b.orderCode")
  543. ->where($condition)->count();
  544. $total=ceil($count/$size);
  545. $page = $page>$total ? intval($total):$page;
  546. $list=Db::name("trade_return")->alias("a")->leftJoin("assoc b","a.logNo=b.viceCode")
  547. ->leftJoin("qrd_info c","c.sequenceNo=b.orderCode")
  548. ->field("a.*,b.orderCode,c.qrdSource,goodNo,goodName,qrdType,c.ownerName,c.ownerid,c.department,c.poCode,c.platName,b.cancel_fee,c.customerName")
  549. ->where($condition)->page($page,$size)->order("a.addtime desc")->select();
  550. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  551. }
  552. //退款状态审核 0 待审核 1 财务审核 2 财务驳回
  553. public function returnStatus(){
  554. $returnCode=isset($this->post['returnCode'])&&$this->post['returnCode']!=''?trim($this->post['returnCode']):"";
  555. if($returnCode==''){
  556. return error_show(1004,"参数 returnCode 不能为空");
  557. }
  558. $returninfo =Db::name("trade_return")->where(["returnCode"=>$returnCode,"is_del"=>0])->find();
  559. if($returninfo==false){
  560. return error_show(1004,"退款申请数据未找到");
  561. }
  562. $status=isset($this->post['status']) &&$this->post['status']!=''?intval($this->post['status']) : '';
  563. if($status==''){
  564. return error_show(1004,"参数 status 不能为空");
  565. }
  566. $return_img = isset($this->post['return_img'])&&$this->post['return_img']!=''?trim($this->post['return_img']):"";
  567. $remark = isset($this->post['remark'])&&$this->post['remark']!=''?trim($this->post['remark']):"";
  568. $loginfo = Db::name("trade_pool")->where(["logNo"=>$returninfo['logNo'],"is_del"=>0])->find();
  569. if($loginfo==false){
  570. return error_show(1004,"认领资金信息未找到");
  571. }
  572. if($loginfo['status']!=2)return error_show(1004,"认领资金信息审核未通过");
  573. Db::startTrans();
  574. try{
  575. $update=["status"=>$status,"return_img"=>$return_img,"remark"=>$remark,"updatetime"=>date("Y-m-d H:i:s")];
  576. $up =Db::name("trade_return")->where($returninfo)->update($update);
  577. if($up){
  578. if($status==1){
  579. $qrdArr=Db::name("assoc")->where(["viceCode"=>$returninfo['logNo'],"status"=>2,"is_del"=>0])->select()
  580. ->toArray();
  581. if(!empty($qrdArr)){
  582. foreach ($qrdArr as $value){
  583. $qrd =Db::name("qrd_info")->where(["sequenceNo"=>$value['orderCode']])->field("id,status,pay_fee,apay_fee,wpay_fee,pay_status,totalPrice")->findOrEmpty();
  584. if(empty($qrd)){
  585. Db::rollback();
  586. return error_show(1005,"未找到销售单数据");
  587. }
  588. if($qrd['apay_fee']<$value['cancel_fee']){
  589. Db::rollback();
  590. return error_show(1005,"销售单待付金额不足");
  591. }
  592. $update =[
  593. "wpay_fee"=>$qrd['wpay_fee']+$value['cancel_fee'],
  594. "apay_fee"=>$qrd['apay_fee']-$value['cancel_fee'],
  595. "pay_status"=>($qrd['apay_fee']-$value['cancel_fee'])==0 && $qrd['pay_fee']==0 ? 1:2,
  596. "status"=>$qrd['pay_fee']==0 && ($qrd['apay_fee']-$value['cancel_fee'])==0 ?0:1,
  597. "updatetime"=>date("Y-m-d H:i:s")
  598. ];
  599. $qrdup =Db::name("qrd_info")->where($qrd)->update($update);
  600. if($qrdup==false){
  601. Db::rollback();
  602. return error_show(1005,"销售单更新失败");
  603. }
  604. $asscup =[
  605. "status"=>3,
  606. "updatetime"=>date("Y-m-d H:i:s")
  607. ];
  608. $assc=Db::name("assoc")->where($value)->update($asscup);
  609. if($assc==false){
  610. Db::rollback();
  611. return error_show(1005,"销售单更新失败");
  612. }
  613. $report=ReportCode::where(["qrdNo"=>$value['orderCode']])->find();
  614. if($report)$report->setField("returnTrad",$returnCode);
  615. }
  616. }
  617. $logup =["status"=>$returninfo['type']==1?5:4,"updatetime"=>date("Y-m-d H:i:s")];
  618. $upde =Db::name("trade_pool")->where($loginfo)->update($logup);
  619. if($upde==false){
  620. Db::rollback();
  621. return error_show(1005,"资金认领信息更新失败");
  622. }
  623. // if($returninfo['type']==1){
  624. $trade =Db::name("trade")->where(["tradNo"=>$returninfo['tradNo'],"is_del"=>0])->find();
  625. if($trade==false){
  626. Db::rollback();
  627. return error_show(1005,"资金信息未找到");
  628. }
  629. if($trade['used_fee']<$loginfo['total_fee']){
  630. Db::rollback();
  631. return error_show(1005,"资金信息已认领金额不足");
  632. }
  633. $tradup =[
  634. "used_fee"=>$trade['used_fee']-$loginfo['total_fee'],
  635. "balance"=>$trade['balance']+$loginfo['total_fee'],
  636. "status"=>($trade['used_fee']-$loginfo['total_fee'])==0 ?1 :2,
  637. "updatetime"=>date("Y-m-d H:i:s")
  638. ];
  639. $updaT=Db::name("trade")->where($trade)->update($tradup);
  640. if($updaT==false){
  641. Db::rollback();
  642. return error_show(1005,"资金信息更新失败");
  643. }
  644. // }
  645. }
  646. Db::commit();
  647. return app_show(0,"退款申请审核成功");
  648. }
  649. Db::rollback();
  650. return error_show(1004,'审核状态失败');
  651. }catch (\Exception $e){
  652. Db::rollback();
  653. return error_show(1004,$e->getMessage());
  654. }
  655. }
  656. //退款申请详情
  657. public function returnInfo(){
  658. $returnCode=isset($this->post['returnCode'])&&$this->post['returnCode']!=''?trim($this->post['returnCode']):"";
  659. if($returnCode==''){
  660. return error_show(1004,"参数 returnCode 不能为空");
  661. }
  662. $returninfo =Db::name("trade_return")->where(["returnCode"=>$returnCode,"is_del"=>0])->find();
  663. if($returninfo==false){
  664. return error_show(1004,"退款申请数据未找到");
  665. }
  666. $trade = Db::name("trade")->where(["tradNo"=>$returninfo['tradNo'],"is_del"=>0])->find();
  667. $returninfo['trade_out']= $trade['trade_out']??"";
  668. $returninfo['trade_in']= $trade['trade_in']??"";
  669. $returninfo['trade_bank']= $trade['trade_bank']??"";
  670. $returninfo['trade_time']= $trade['trade_time']??"";
  671. $returninfo['customerNo']= $trade['customerNo']??"";
  672. $returninfo['companyNo']= $trade['companyNo']??"";
  673. $returninfo['total_fee']= $trade['total_fee']??"";
  674. $returninfo['balance']= $trade['balance']??"";
  675. $returninfo['used_fee']= $trade['used_fee']??"";
  676. $pool =Db::name("trade_pool")->where(["logNo"=>$returninfo['logNo'],"is_del"=>0])->find();
  677. $returninfo['log_total_fee']= $pool['total_fee']??"";
  678. $returninfo['log_apply_id']= $pool['apply_id']??"";
  679. $returninfo['log_apply_name']= $pool['apply_name']??"";
  680. $orderinfo = Db::name("assoc")->alias("a")->leftJoin("qrd_info c","a.orderCode=c.sequenceNo")
  681. ->where(["a.viceCode"=>$returninfo['logNo'],"a.is_del"=>0,"a.status"=>[1,2]])
  682. ->order("a.addtime desc")
  683. ->field("c.*")
  684. ->findOrEmpty();
  685. $returninfo['orderinfo'] = $orderinfo;
  686. return app_show(0,"获取成功",$returninfo);
  687. }
  688. /**
  689. * 显示创建资源表单页.
  690. *
  691. * @return \think\Response
  692. */
  693. public function importTrade()
  694. {
  695. $files = $this->request->file("excel");
  696. $data = upload($files,$files->getOriginalExtension());
  697. if($data['code']!=0){
  698. return error_show(1004,$data['msg']);
  699. }
  700. $trade = $data['data'];
  701. $list = [];
  702. foreach ( $trade as $key => $value) {
  703. if (!isset($value[0]) || $value[0] == '') {
  704. //return ['code' => 1003, "msg" => '交易时间不能为空'];
  705. return error_show( 1003, '第'.($key+1).'行收款方公司编号不能为空!');
  706. }
  707. if (!isset($value[4]) || $value[4] == '') {
  708. // return ['code' => 1003, "msg" => '交易行名不能为空'];
  709. return error_show( 1003, '第'.($key+1).'行收入金额不能为空!');
  710. }
  711. if (!isset($value[8]) || $value[8] == '') {
  712. // return ['code' => 1003, "msg" => '对方账户不能为空'];
  713. return error_show( 1003, '第'.($key+1).'行对方账户不能为空!');
  714. }
  715. if (!isset($value[9]) || $value[9] == '') {
  716. // return ['code' => 1003, "msg" => '对方户名不能为空'];
  717. return error_show( 1003, '第'.($key+1).'行对方户名不能为空!');
  718. }
  719. if ($key == 0) {
  720. if ($value[0] != '收款方公司编号') {
  721. // return ['code' => 1003, "msg" => '模板第一列为必须为交易时间!'];
  722. return error_show( 1003, '模板第一列为必须为收款方公司编号!');
  723. }
  724. if ($value[4] != '收入金额') {
  725. // return ['code' => 1003, "msg" => '模板第二列为必须为收入金额!'];
  726. return error_show( 1003, '模板第五列为必须为收入金额!');
  727. }
  728. if ($value[6] != '交易行名') {
  729. //return ['code' => 1003, "msg" => '模板第五列为必须为交易行名!'];
  730. return error_show( 1003, '模板第七列为必须为交易行名!');
  731. }
  732. if ($value[8] != '对方账号') {
  733. // return ['code' => 1003, "msg" => '模板第七列为必须为对方账号!'];
  734. return error_show( 1003, '模板第九列为必须为对方账号!');
  735. }
  736. if ($value[9] != '对方户名') {
  737. // return ['code' => 1003, "msg" => '模板第八列为必须为对方户名!'];
  738. return error_show( 1003, '模板第十列为必须为对方户名!');
  739. }
  740. continue;
  741. }
  742. $company =Db::name("company_info")->where(["companyNo"=>$value[0]])->findOrEmpty();
  743. if(empty($company)){
  744. return error_show( 1003, "业务公司编号不存在{$value[0]}");
  745. }
  746. $total_fee = $value[4];
  747. $type = 0;
  748. $time = explode(" ", $value[3]);
  749. $list[$key]["tradeTime"] = date("Y-m-d", strtotime($time[0])) . " " . (isset($time[1]) ? $time[1] : "00:00:00");
  750. $list[$key]["trade_fee"] = str_replace(",","",$total_fee);
  751. $list[$key]["trade_bank"] = $value[6];
  752. $list[$key]["trade_account"] = $value[8];
  753. $list[$key]["trade_out"] = $value[9];
  754. $list[$key]["trade_in"] = $value[1]??$company['company_name'];
  755. $list[$key]["trade_type"] = $type;
  756. $list[$key]["trade_used"] = isset($value[10]) ? $value[10] : "";
  757. $list[$key]["trade_remark"] = '';
  758. $list[$key]["companyNo"] = $value[0];
  759. $list[$key]["trade_in_account"] = $value[2]??"";
  760. }
  761. if(empty($list)){
  762. return error_show( 1003, '导入数据不能为空!');
  763. }
  764. Db::startTrans();
  765. try{
  766. $tra=[];
  767. foreach ($list as $value) {
  768. $temp = [];
  769. $temp["tradNo"] = makeStr('S');
  770. $temp['trade_time'] = $value['tradeTime'];
  771. $temp['total_fee'] = $value['trade_fee'];
  772. $temp['trade_bank'] = $value['trade_bank'];
  773. $temp['trade_account'] = $value['trade_account'];
  774. $temp['trade_type'] =$value['trade_type'];
  775. $temp['trade_out'] = $value['trade_out'];
  776. $temp['trade_in'] = $value['trade_in'];
  777. $temp['trade_in_account'] = $value['trade_in_account'];
  778. $temp['companyNo'] = $value['companyNo'];
  779. $temp['trade_used'] = $value['trade_used'];
  780. $temp['trade_remark'] = $value['trade_remark'];
  781. $temp['balance'] =$value['trade_fee'];
  782. $temp['addtime'] = date("Y-m-d H:i:s");
  783. $temp['updatetime'] = date("Y-m-d H:i:s");
  784. $tra[]=$temp;
  785. }
  786. $list = Db::name('trade')->insertAll($tra);
  787. if($list==count($tra)){
  788. Db::commit();
  789. return app_show(0, "资金导入成功");
  790. }else{
  791. Db::rollback();
  792. return app_show(1004, "资金导入失败");
  793. }
  794. }catch (\Exception $e){
  795. Db::rollback();
  796. return app_show(1004, $e->getMessage());
  797. }
  798. }
  799. /**
  800. * @return \think\response\Json|void
  801. */
  802. public function importTradeByArr()
  803. {
  804. $trade =isset($this->post['data']) &&!empty($this->post['data'])? $this->post['data']:[];
  805. if(!is_array($trade) || empty($trade) ) return error_show( 1003,"参数 data 不能为空");
  806. $list = [];
  807. foreach ( $trade as $key => $value) {
  808. if (!isset($value[0]) || $value[0] == '') {
  809. //return ['code' => 1003, "msg" => '交易时间不能为空'];
  810. return error_show( 1003, '第'.($key+1).'行收款方公司编号不能为空!');
  811. }
  812. if (!isset($value[2]) || $value[2] == '') {
  813. //return ['code' => 1003, "msg" => '交易时间不能为空'];
  814. return error_show( 1003, '第'.($key+1).'行收款账户不能为空!');
  815. }
  816. if (!isset($value[3]) || $value[3] == '') {
  817. //return ['code' => 1003, "msg" => '交易时间不能为空'];
  818. return error_show( 1003, '第'.($key+1).'行交易时间不能为空!');
  819. }
  820. if (!isset($value[4]) || $value[4] == '') {
  821. // return ['code' => 1003, "msg" => '交易行名不能为空'];
  822. return error_show( 1003, '第'.($key+1).'行收入金额不能为空!');
  823. }
  824. if (!isset($value[6]) || $value[6] == '') {
  825. // return ['code' => 1003, "msg" => '交易行名不能为空'];
  826. return error_show( 1003, '第'.($key+1).'行交易银行名称不能为空!');
  827. }
  828. if (!isset($value[8]) || $value[8] == '') {
  829. // return ['code' => 1003, "msg" => '对方账户不能为空'];
  830. return error_show( 1003, '第'.($key+1).'行对方账户不能为空!');
  831. }
  832. if (!isset($value[9]) || $value[9] == '') {
  833. // return ['code' => 1003, "msg" => '对方户名不能为空'];
  834. return error_show( 1003, '第'.($key+1).'行对方户名不能为空!');
  835. }
  836. // if ($key == 0) {
  837. // if ($value[0] != '收款方公司编号') {
  838. // // return ['code' => 1003, "msg" => '模板第一列为必须为交易时间!'];
  839. // return error_show( 1003, '模板第一列为必须为收款方公司编号!');
  840. // }
  841. // if ($value[4] != '收入金额') {
  842. // // return ['code' => 1003, "msg" => '模板第二列为必须为收入金额!'];
  843. // return error_show( 1003, '模板第五列为必须为收入金额!');
  844. // }
  845. //
  846. // if ($value[6] != '交易行名') {
  847. // //return ['code' => 1003, "msg" => '模板第五列为必须为交易行名!'];
  848. // return error_show( 1003, '模板第七列为必须为交易行名!');
  849. // }
  850. // if ($value[8] != '对方账号') {
  851. // // return ['code' => 1003, "msg" => '模板第七列为必须为对方账号!'];
  852. // return error_show( 1003, '模板第九列为必须为对方账号!');
  853. // }
  854. // if ($value[9] != '对方户名') {
  855. // // return ['code' => 1003, "msg" => '模板第八列为必须为对方户名!'];
  856. // return error_show( 1003, '模板第十列为必须为对方户名!');
  857. // }
  858. // continue;
  859. // }
  860. $company =Db::name("company_info")->where(["companyNo"=>$value[0]])->findOrEmpty();
  861. if(empty($company)){
  862. return error_show( 1003, "业务公司编号不存在{$value[0]}");
  863. }
  864. $total_fee = $value[4];
  865. $type = 0;
  866. $time = explode(" ", $value[3]);
  867. $list[$key]["tradeTime"] = date("Y-m-d", strtotime($time[0])) . " " . (isset($time[1]) ? $time[1] : "00:00:00");
  868. $list[$key]["trade_fee"] = str_replace(",","",$total_fee);
  869. $list[$key]["trade_bank"] = $value[6];
  870. $list[$key]["trade_account"] = $value[8];
  871. $list[$key]["trade_out"] = $value[9];
  872. $list[$key]["trade_in"] = $value[1]??$company['company_name'];
  873. $list[$key]["trade_type"] = $type;
  874. $list[$key]["trade_used"] = isset($value[10]) ? $value[10] : "";
  875. $list[$key]["trade_remark"] = '';
  876. $list[$key]["companyNo"] = $value[0];
  877. $list[$key]["trade_in_account"] = $value[2]??"";
  878. }
  879. if(empty($list)){
  880. return error_show( 1003, '导入数据不能为空!');
  881. }
  882. Db::startTrans();
  883. try{
  884. $tra=[];
  885. foreach ($list as $value) {
  886. $temp = [];
  887. $temp["tradNo"] = makeStr('S');
  888. $temp['trade_time'] = $value['tradeTime'];
  889. $temp['total_fee'] = $value['trade_fee'];
  890. $temp['trade_bank'] = $value['trade_bank'];
  891. $temp['trade_account'] = $value['trade_account'];
  892. $temp['trade_type'] =$value['trade_type'];
  893. $temp['trade_out'] = $value['trade_out'];
  894. $temp['trade_in'] = $value['trade_in'];
  895. $temp['trade_in_account'] = $value['trade_in_account'];
  896. $temp['companyNo'] = $value['companyNo'];
  897. $temp['trade_used'] = $value['trade_used'];
  898. $temp['trade_remark'] = $value['trade_remark'];
  899. $temp['balance'] =$value['trade_fee'];
  900. $temp['addtime'] = date("Y-m-d H:i:s");
  901. $temp['updatetime'] = date("Y-m-d H:i:s");
  902. $tra[]=$temp;
  903. }
  904. $list = Db::name('trade')->insertAll($tra);
  905. if($list==count($tra)){
  906. Db::commit();
  907. return app_show(0, "资金导入成功");
  908. }else{
  909. Db::rollback();
  910. return app_show(1004, "资金导入失败");
  911. }
  912. }catch (\Exception $e){
  913. Db::rollback();
  914. return app_show(1004, $e->getMessage());
  915. }
  916. }
  917. }