|
@@ -334,7 +334,50 @@ func TryOutToFormalByWxUser(companyId, productId, sellerId, companyApprovalId, c
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
+ itemuserProductDetail := new(UserProduct)
|
|
|
+ sql = ` SELECT * FROM user_product AS a WHERE user_id = ? AND product_id = ? `
|
|
|
+ err = o.Raw(sql, userId, productId).QueryRow(&itemuserProductDetail)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ updateStartDateTime, tmpErr := time.Parse(utils.FormatDate, itemuserProductDetail.StartDate)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ updateEndDateTime, tmpErr := time.Parse(utils.FormatDate, itemuserProductDetail.EndDate)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
+ //校验原始数据中的开始日期是否小于合同内的开始日期,如果小于,那么变更为原先的合同开始日期
|
|
|
+ tmpStartDate, tmpErr := time.Parse(utils.FormatDate, startDate)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if tmpStartDate.Before(updateStartDateTime) {
|
|
|
+ updateStartDateTime = tmpStartDate
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验原始数据中的结束日期是否大于合同内的结束日期,如果大于,那么变更为原先的合同结束日期
|
|
|
+ tmpEndDate, tmpErr := time.Parse(utils.FormatDate, endDate)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if tmpEndDate.After(updateEndDateTime) {
|
|
|
+ updateEndDateTime = tmpEndDate
|
|
|
+ }
|
|
|
+
|
|
|
+ sql = `UPDATE user_product SET status='正式', start_date=?, end_date=?,modify_time=NOW() WHERE WHERE user_id = ? AND product_id = ? `
|
|
|
+ _, err = to.Raw(sql, updateStartDateTime, updateEndDateTime, userId, productId).Exec()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
sql = `UPDATE company_approval SET approve_status='已审批',approve_time=NOW(),modify_time=NOW() WHERE company_approval_id=? AND company_id=? AND product_id=? `
|
|
@@ -342,6 +385,7 @@ func TryOutToFormalByWxUser(companyId, productId, sellerId, companyApprovalId, c
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
items := make([]*UserReportPermission, 0)
|
|
|
sql = `SELECT * FROM user_report_permission WHERE company_id=? AND product_id=? `
|
|
|
_, err = to.Raw(sql, companyId, productId).QueryRows(&items)
|