123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- namespace app\cxinv\model;
- class QrdInfo extends Base
- {
- //设置字段信息
- protected $schema = [
- 'id' =>'bigint',//
- 'name' =>'varchar',//确认单名称
- 'sequenceNo' =>'varchar',//确认单编号
- 'ownerName' =>'varchar',//销售员
- 'ownerid' =>'int',//销售员id
- 'managerid' =>'int',//
- 'manager' =>'varchar',//
- 'department' =>'varchar',//部门
- 'createdTime' =>'datetime',//销售单创建时间
- 'status' =>'tinyint',//销售单状态
- 'qrdType' =>'tinyint',//销售单类型
- 'qrdSource' =>'tinyint',//销售单来源
- 'companyNo' =>'varchar',//业务企业编号
- 'companyName' =>'varchar',//业务企业名称
- 'customerNo' =>'varchar',//客户编号
- 'customerName' =>'varchar',//客户名称
- 'poCode' =>'varchar',//po编号
- 'platName' =>'varchar',//平台名称
- 'platform_type' =>'tinyint',//平台类型 0 无 1 ToB 2ToC
- 'workCode' =>'varchar',//业务编号
- 'zxCode' =>'varchar',//咨询单编号
- 'goodNo' =>'varchar',//商品编号
- 'goodName' =>'varchar',//商品名称
- 'goodBrand' =>'varchar',//商品品牌
- 'firstCat' =>'varchar',//一级分类
- 'secCat' =>'varchar',//二级分类
- 'thirdCat' =>'varchar',//三级分类
- 'catInfo' =>'text',//分类详情
- 'fundCode' =>'varchar',//核算编码
- 'goodMaterial' =>'varchar',//商品材质
- 'goodUnit' =>'varchar',//商品单位
- 'goodDesc' =>'varchar',//工艺说明
- 'goodType' =>'varchar',//商品类型
- 'goodModel' =>'varchar',//商品型号
- 'isStock' =>'tinyint',//是否库存品
- 'metalsType' =>'varchar',//贵金属种类
- 'weight' =>'decimal',//商品重量
- 'goldPrice' =>'decimal',//贵金属单价
- 'deliveryDay' =>'varchar',//物流天数
- 'workDay' =>'varchar',//工期
- 'tax' =>'varchar',//税率
- 'goodNum' =>'int',//销售数量
- 'goodPrice' =>'decimal',//产品单价
- 'totalPrice' =>'decimal',//货款总额
- 'total_origin_price' =>'decimal',//成本总额
- 'total_plan_price' =>'decimal',//预计成本总额
- 'sendNum' =>'int',//已发货数量
- 'wsendNum' =>'int',//未发货数量
- 'apay_fee' =>'decimal',//已付款
- 'pay_fee' =>'decimal',//
- 'wpay_fee' =>'decimal',//未付款
- 'inv_fee' =>'decimal',//
- 'ainv_fee' =>'decimal',//已开票
- 'winv_fee' =>'decimal',//未开票
- 'is_diff' =>'tinyint',//是否有工差
- 'sendType' =>'varchar',//发货方式
- 'sendStatus' =>'varchar',//发货状态
- 'pay_status' =>'tinyint',//收款状态
- 'inv_status' =>'tinyint',//开票状态
- 'remark' =>'varchar',//备注
- 'cxCode' =>'varchar',//拆单原编号
- 'invtime' =>'varchar',//最近开票时间
- 'paytime' =>'varchar',//
- 'diff_weight' =>'decimal',//工差重量
- 'diff_fee' =>'decimal',//工差金额
- 'area' =>'varchar',//公司
- 'customerAttr' =>'varchar',//客户属性
- 'branch' =>'varchar',//分公司
- 'cgdNo' =>'varchar',//采购单号
- 'thNum' =>'int',//退货数量
- 'th_fee' =>'decimal',//退货金额
- 'is_comon' =>'tinyint',//是否是通用订单 0否1是
- 'is_del' =>'tinyint',//是否删除
- 'addtime' =>'datetime',//
- 'updatetime' =>'datetime',//
- 'pay_source' =>'varchar',//支付渠道
- 'inv_tag' =>'tinyint',//开票标签
- 'pay_tag' =>'tinyint',//回款标签
- 'inv_tag_fee' =>'decimal',//开票票标签金额
- 'pay_tag_fee' =>'decimal',//回款标签金额
- ];
- protected $createTime = 'addtime';
- protected $updateTime = 'updatetime';
- public static function CheckQrd($orderCode,&$data)
- {
- $qrdinf =self::where(['sequenceNo|cxCode'=>$orderCode,'is_del'=>0])
- ->field('sequenceNo,ownerName,companyName,inv_tag,pay_tag')->select()->toArray();
- if(!empty($qrdinf)){
- foreach ($qrdinf as $item){
- if($item['inv_tag']==1){
- $uname= TagLog::alias('a')
- ->join('order_tag b','a.tag_id=b.id','left')
- ->where(['code'=>$item['sequenceNo'],'b.type'=>2])
- ->order('a.id desc')
- ->value('creater','');
- $data[]=['type'=>'结算销售单开票标签','username'=>$uname,'orderCode'=>$item['sequenceNo'],'companyName'=>$item['companyName']];
- }
- if($item['pay_tag']==1){
- $uname= TagLog::alias('a')
- ->join('order_tag b','a.tag_id=b.id','left')
- ->where(['code'=>$item['sequenceNo'],'b.type'=>1])
- ->order('a.id desc')
- ->value('creater','');
- $data[]=['type'=>'结算销售单付款标签','username'=> $uname,'orderCode'=>$item['sequenceNo'],'companyName'=>$item['companyName']];
- }
- Assoc::CheckQrd($item['sequenceNo'],$data);
- }
- }
- }
- public static function AddTag($model,$tag_id)
- { $tag= OrderTag::where('id',$tag_id)->findOrEmpty();
- if($tag->isEmpty())throw new \Exception('标签不存在');
- try{
- $total_fee= $tag['type']==3?$model->wpay_fee: $model->winv_fee;
- TagLog::CheckOrderInfo($model->sequenceNo,$total_fee,$tag['type']);
- $tagdata=[
- 'code'=>$model->sequenceNo,
- 'tag_id'=>$tag_id,
- 'creater'=>$model->creater,
- 'createrid'=>$model->createrid,
- 'tag_fee'=>$total_fee,
- 'tag_img'=>'',
- 'tag_remark'=>'',
- 'status'=>1,
- ];
- TagLog::create($tagdata);
- }catch (\Exception $e){
- throw new \Exception($e->getMessage());
- }
- }
- }
|