QrdInfo.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace app\cxinv\model;
  3. class QrdInfo extends Base
  4. {
  5. //设置字段信息
  6. protected $schema = [
  7. 'id' =>'bigint',//
  8. 'name' =>'varchar',//确认单名称
  9. 'sequenceNo' =>'varchar',//确认单编号
  10. 'ownerName' =>'varchar',//销售员
  11. 'ownerid' =>'int',//销售员id
  12. 'managerid' =>'int',//
  13. 'manager' =>'varchar',//
  14. 'department' =>'varchar',//部门
  15. 'createdTime' =>'datetime',//销售单创建时间
  16. 'status' =>'tinyint',//销售单状态
  17. 'qrdType' =>'tinyint',//销售单类型
  18. 'qrdSource' =>'tinyint',//销售单来源
  19. 'companyNo' =>'varchar',//业务企业编号
  20. 'companyName' =>'varchar',//业务企业名称
  21. 'customerNo' =>'varchar',//客户编号
  22. 'customerName' =>'varchar',//客户名称
  23. 'poCode' =>'varchar',//po编号
  24. 'platName' =>'varchar',//平台名称
  25. 'platform_type' =>'tinyint',//平台类型 0 无 1 ToB 2ToC
  26. 'workCode' =>'varchar',//业务编号
  27. 'zxCode' =>'varchar',//咨询单编号
  28. 'goodNo' =>'varchar',//商品编号
  29. 'goodName' =>'varchar',//商品名称
  30. 'goodBrand' =>'varchar',//商品品牌
  31. 'firstCat' =>'varchar',//一级分类
  32. 'secCat' =>'varchar',//二级分类
  33. 'thirdCat' =>'varchar',//三级分类
  34. 'catInfo' =>'text',//分类详情
  35. 'fundCode' =>'varchar',//核算编码
  36. 'goodMaterial' =>'varchar',//商品材质
  37. 'goodUnit' =>'varchar',//商品单位
  38. 'goodDesc' =>'varchar',//工艺说明
  39. 'goodType' =>'varchar',//商品类型
  40. 'goodModel' =>'varchar',//商品型号
  41. 'isStock' =>'tinyint',//是否库存品
  42. 'metalsType' =>'varchar',//贵金属种类
  43. 'weight' =>'decimal',//商品重量
  44. 'goldPrice' =>'decimal',//贵金属单价
  45. 'deliveryDay' =>'varchar',//物流天数
  46. 'workDay' =>'varchar',//工期
  47. 'tax' =>'varchar',//税率
  48. 'goodNum' =>'int',//销售数量
  49. 'goodPrice' =>'decimal',//产品单价
  50. 'totalPrice' =>'decimal',//货款总额
  51. 'total_origin_price' =>'decimal',//成本总额
  52. 'total_plan_price' =>'decimal',//预计成本总额
  53. 'sendNum' =>'int',//已发货数量
  54. 'wsendNum' =>'int',//未发货数量
  55. 'apay_fee' =>'decimal',//已付款
  56. 'pay_fee' =>'decimal',//
  57. 'wpay_fee' =>'decimal',//未付款
  58. 'inv_fee' =>'decimal',//
  59. 'ainv_fee' =>'decimal',//已开票
  60. 'winv_fee' =>'decimal',//未开票
  61. 'is_diff' =>'tinyint',//是否有工差
  62. 'sendType' =>'varchar',//发货方式
  63. 'sendStatus' =>'varchar',//发货状态
  64. 'pay_status' =>'tinyint',//收款状态
  65. 'inv_status' =>'tinyint',//开票状态
  66. 'remark' =>'varchar',//备注
  67. 'cxCode' =>'varchar',//拆单原编号
  68. 'invtime' =>'varchar',//最近开票时间
  69. 'paytime' =>'varchar',//
  70. 'diff_weight' =>'decimal',//工差重量
  71. 'diff_fee' =>'decimal',//工差金额
  72. 'area' =>'varchar',//公司
  73. 'customerAttr' =>'varchar',//客户属性
  74. 'branch' =>'varchar',//分公司
  75. 'cgdNo' =>'varchar',//采购单号
  76. 'thNum' =>'int',//退货数量
  77. 'th_fee' =>'decimal',//退货金额
  78. 'is_comon' =>'tinyint',//是否是通用订单 0否1是
  79. 'is_del' =>'tinyint',//是否删除
  80. 'addtime' =>'datetime',//
  81. 'updatetime' =>'datetime',//
  82. 'pay_source' =>'varchar',//支付渠道
  83. 'inv_tag' =>'tinyint',//开票标签
  84. 'pay_tag' =>'tinyint',//回款标签
  85. 'inv_tag_fee' =>'decimal',//开票票标签金额
  86. 'pay_tag_fee' =>'decimal',//回款标签金额
  87. ];
  88. protected $createTime = 'addtime';
  89. protected $updateTime = 'updatetime';
  90. public static function CheckQrd($orderCode,&$data)
  91. {
  92. $qrdinf =self::where(['sequenceNo|cxCode'=>$orderCode,'is_del'=>0])
  93. ->field('sequenceNo,ownerName,companyName,inv_tag,pay_tag')->select()->toArray();
  94. if(!empty($qrdinf)){
  95. foreach ($qrdinf as $item){
  96. if($item['inv_tag']==1){
  97. $uname= TagLog::alias('a')
  98. ->join('order_tag b','a.tag_id=b.id','left')
  99. ->where(['code'=>$item['sequenceNo'],'b.type'=>2])
  100. ->order('a.id desc')
  101. ->value('creater','');
  102. $data[]=['type'=>'结算销售单开票标签','username'=>$uname,'orderCode'=>$item['sequenceNo'],'companyName'=>$item['companyName']];
  103. }
  104. if($item['pay_tag']==1){
  105. $uname= TagLog::alias('a')
  106. ->join('order_tag b','a.tag_id=b.id','left')
  107. ->where(['code'=>$item['sequenceNo'],'b.type'=>1])
  108. ->order('a.id desc')
  109. ->value('creater','');
  110. $data[]=['type'=>'结算销售单付款标签','username'=> $uname,'orderCode'=>$item['sequenceNo'],'companyName'=>$item['companyName']];
  111. }
  112. Assoc::CheckQrd($item['sequenceNo'],$data);
  113. }
  114. }
  115. }
  116. public static function AddTag($model,$tag_id)
  117. { $tag= OrderTag::where('id',$tag_id)->findOrEmpty();
  118. if($tag->isEmpty())throw new \Exception('标签不存在');
  119. try{
  120. $total_fee= $tag['type']==3?$model->wpay_fee: $model->winv_fee;
  121. TagLog::CheckOrderInfo($model->sequenceNo,$total_fee,$tag['type']);
  122. $tagdata=[
  123. 'code'=>$model->sequenceNo,
  124. 'tag_id'=>$tag_id,
  125. 'creater'=>$model->creater,
  126. 'createrid'=>$model->createrid,
  127. 'tag_fee'=>$total_fee,
  128. 'tag_img'=>'',
  129. 'tag_remark'=>'',
  130. 'status'=>1,
  131. ];
  132. TagLog::create($tagdata);
  133. }catch (\Exception $e){
  134. throw new \Exception($e->getMessage());
  135. }
  136. }
  137. }