소스 검색

no message

zhangchuanxing 3 달 전
부모
커밋
b4cf4e390b
2개의 변경된 파일28개의 추가작업 그리고 0개의 파일을 삭제
  1. 12 0
      models/company/company_product.go
  2. 16 0
      services/company_contract.go

+ 12 - 0
models/company/company_product.go

@@ -711,3 +711,15 @@ func UpdateCompanyProductsellerInit(seller_id_init int, seller_name_init string,
 	_, err = o.Raw(sql, seller_id_init, seller_name_init, companyId, productId).Exec()
 	return
 }
+
+// 合同未到期更新对应销售的信息
+func UpdateCompanyProductSellerUnexpired(sellerId, shareSellerInit int, sellerName, shareSeller string, companyContractId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_product SET
+                            seller_id_last = ? , 
+                            seller_name_last = ? , 
+                            share_seller_last = ? , 
+                            share_seller_id_last = ?  WHERE companyId = ?  AND product_id= 2 `
+	_, err = o.Raw(sql, sellerId, sellerName, shareSellerInit, shareSeller, companyContractId).Exec()
+	return
+}

+ 16 - 0
services/company_contract.go

@@ -430,6 +430,7 @@ func UpdateCompanyContractSellerMove(companyId, productId int) (moveMap map[stri
 		return
 	}
 
+	var updateCompanyProduct bool
 	//更新还没有生效的合同
 	{
 		var condition string
@@ -451,6 +452,12 @@ func UpdateCompanyContractSellerMove(companyId, productId int) (moveMap map[stri
 					return
 				}
 			}
+			e = company.UpdateCompanyProductSellerUnexpired(cp.SellerId, cp.ShareSellerId, cp.SellerName, cp.ShareSeller, cp.CompanyId)
+			if e != nil {
+				err = errors.New("UpdateCompanyProductSellerUnexpired, Err: " + e.Error())
+				return
+			}
+			updateCompanyProduct = true
 		}
 	}
 
@@ -475,6 +482,15 @@ func UpdateCompanyContractSellerMove(companyId, productId int) (moveMap map[stri
 					return
 				}
 			}
+
+			if !updateCompanyProduct {
+				e = company.UpdateCompanyProductSellerUnexpired(cp.SellerId, cp.ShareSellerId, cp.SellerName, cp.ShareSeller, cp.CompanyId)
+				if e != nil {
+					err = errors.New("UpdateCompanyProductSellerUnexpired, Err: " + e.Error())
+					return
+				}
+			}
+
 		}
 	}