- Store and StoreMap add DeletedAt.

This commit is contained in:
gazebo
2018-09-20 10:07:58 +08:00
parent f874c37d14
commit 9d88344ddb
14 changed files with 206 additions and 172 deletions

View File

@@ -26,6 +26,7 @@ type tJdStoreInfo struct {
JdStoreStatus int
VendorStoreID string `orm:"column(vendor_store_id)"`
RealLastOperator string
SyncStatus int
}
func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error) {
@@ -82,15 +83,22 @@ func (p *PurchaseHandler) UpdateStore(storeID int, userName string) (err error)
var store tJdStoreInfo
sql := `
SELECT t1.*, city.jd_code jd_city_code, district.jd_code jd_district_code, t2.status jd_store_status, t2.vendor_store_id,
IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator
IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status
FROM store t1
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ?
LEFT JOIN place city ON t1.city_code = city.code
LEFT JOIN place district ON t1.district_code = district.code
WHERE t1.id = ?`
WHERE t1.id = ?
ORDER BY t2.updated_at DESC
LIMIT 1;
`
if err = dao.GetRow(db, &store, sql, model.VendorIDJD, storeID); err == nil {
outSystemID := ""
if store.SyncStatus&model.SyncFlagDeletedMask == 0 {
outSystemID = utils.Int2Str(int(store.ID))
}
params := map[string]interface{}{
"outSystemId": utils.Int2Str(int(store.ID)), // todo 直接修改这个字段可能会有问题
"outSystemId": outSystemID, // todo 直接修改这个字段可能会有问题
"stationName": jxutils.ComposeStoreName(store.Name, partner.StoreNameSeparator, VendorStorePrefix),
"stationAddress": store.Address,
"serviceTimeStart1": JxOperationTime2JdOperationTime(store.OpenTime1),